How to take FFT inside ode function ?

3 visualizzazioni (ultimi 30 giorni)
Ole
Ole il 30 Gen 2016
Modificato: Ole il 30 Gen 2016
Matlab is solving ode point by point in t . I want to take FFT inside the function myode. It can taken outside but the way I understand it it needs to be inputted point by point. Is it possible ?
options = odeset('RelTol',3e-14,'AbsTol',[3e-14 3e-14 3e-14 3e-14 3e-14 3e-14 ]);
[t1,x1] = ode45(@myode,[-tmax/2:dt:(tmax/2-dt)],Ni(1:end-1),options); % solve x
function dx=myode(t,x)
R = cos(a*t)
dx = R*x; example
Now I want to take FFT but the ode is calculated point by point.
function dx=myode(t,x)
R = cos(a*t)
t = -tmax/2:dt:(tmax/2-dt) ;
fr = -1/(2*dt):1/tmax:1/(2*dt)-1/tmax;
W1 = exp(1i*k1*z);
Y1 = fftshift(fft(R,resol));
Y1 = Y1.*W1;
y = (ifft(fftshift((Y1))));
dx = y*x; example

Risposte (0)

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by