Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I solve a system od ODE and i save the discrete solution (i.e.: x,y,vx,vy, or a subset of it) in a file.

Then i try to call the DFT on this file but the problem is that i must have also the time in the file to make some analysis for instance something like: {t,x} or {t,vy} !

Clear["Global`*"];
m = {X, Y, Vx, Vy} /. NDSolve[{
       Derivative[1][X][t] == Vx[t],
       Derivative[1][Y][t] == Vy[t],
       Derivative[1][Vx][t] == 
        2 Vy[t] + 
         X[t] - ((1 - mu) (mu + X[t]))/((mu + X[t])^2 + Y[t]^2)^(
         3/2) - (mu (-1 + mu + X[t]))/((-1 + mu + X[t])^2 + Y[t]^2)^(
         3/2),
       Derivative[1][Vy][t] == -2 Vx[t] + 
         Y[t] - ((1 - mu) Y[t])/((mu + X[t])^2 + Y[t]^2)^(3/2) - (
         mu Y[t])/((-1 + mu + X[t])^2 + Y[t]^2)^(3/2),
       X[0] == 0.56, Vx[0] == 0., Y[0] == 0., 
       Vy[0] == 0.929168} /. {mu -> 0.000954}, {X, Y, Vx, Vy}, {t, 0.,
       100.}, MaxSteps -> 100000][[1]];
data1 = Table[Evaluate[m[[#]][t] & /@ {1, 2}], {t, 0., 100., 0.1}]; (*here i put x and y *)
dataX = Table[Evaluate[m[[#]][t] & /@ {1}], {t, 0., 100., 0.1}]; (*only x*)
dataY = Table[Evaluate[m[[#]][t] & /@ {2}], {t, 0., 100., 0.1}]; (*only y*)

Export["Cor56.dat", data1];
data2 = Import["Cor56.dat"];
data1 == data2
ListPlot[Transpose@dataX, Filling -> None]
ListLinePlot[Abs[Fourier[dataX]]]
ListPlot[Transpose@dataY, Filling -> None]
ListLinePlot[Abs[Fourier[dataY]]]
Graphics[Point[data2]];

So the question is, how to put also the time in the file to use the DFT routine on the file?

Thanks.

share|improve this question
1  
Maybe data1 = Table[{t, m[[1]][t], m[[2]][t]}, {t, 0., 100., 0.1}] –  m_goldberg Apr 13 at 15:45
1  
Your calculation of dataX and dataY is a bit strange. When you change m[[#]][t] & /@ {1} in m[[1]][t] and the same for y, you can drop the two Transposes below and all your figures plot just fine. –  Sjoerd C. de Vries Apr 13 at 17:51
    
Yes now it works very well ! thanks a lot ! –  Panichi Pattumeros PapaCastoro Apr 14 at 13:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.