SetDirectory["C:\Program Files\Daedalon"]

SetDirectory["C:\Seth\courses\physics39\phys39_fall06\web-content\chaos"]

Set the directory to where a data file from the Daedalon Pendulum is stored.

myList=Import["test.pha","Table"];

The first two values aren't interesting and can be discarded. The rest of the data comes in groups of four, time, angle, velocity and something else.

Shallow[InputForm[myList]]

Take[myList,6]

myList[[3]]

myList[[10000]]

The first two values are junk, another element is the entire list, then that leaves a 9998 long list with each element containing 4 elements.

Dimensions[myList]

Array[phaseplot,{9998,2}];

For[i=1,i≤9998,i++,
    phaseplot[i,1]=myList[[i+2]][[1]];
 phaseplot[i,2]=myList[[i+2]][[2]];  
]

ListPlot[Array[phaseplot,{9998,2}],PlotRange->All]

For[i=1,i≤9998,i++,
 If[ phaseplot[i,2]<0,phaseplot[i,2]=phaseplot[i,2]+2π,phaseplot[i,2]=phaseplot[i,2] ]
]

Fix the data modulo 2π.

ListPlot[Array[phaseplot,{9998,2}],PlotRange->All]

Make an array 9998 rows long with each row containing 2 entries. Take the last 7000 entries and discard the rest.

data=Array[phaseplot,{9998,2}];

data1=Take[data,-7000];

Plot the data.

ListPlot[data1,PlotRange->All]

FIt the data to a damped cosine.

model= Amp *Exp[-a* t]*Cos[(Sqrt[(ω^2)-(a^2)])t  + θ]+Base

fitted =FindFit[data1,model,{{Amp,1},{Base,2.7}, {ω,6.2},{θ,2.5},{a,.1}},t]

fit =model/.fitted

Make an array of the fitted values.

f1 =Table[fit,{t,0,20,.02}];

Take[f1,6]

Make a 2D array of the time and  fitted values.

data2=Table[{t,fit},{t,0,20,.01}];

Take[data2,6]

Plot[fit,{t,0,20}]

ListPlot[data1,PlotRange->All]

ListPlot[data2,PlotRange->All]

Compare data with fitted data.

ListPlot[{data1,data2},PlotRange->{{6,20},{1.4,3.7}}]

ListPlot[{data1,data2},PlotRange->{{6,8},{1.4,3.7}}]