How to take FFT inside ode function ?

2 次查看(过去 30 天)
Ole
Ole 2016-1-30
编辑: Ole 2016-1-30
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by