How to take FFT inside ode function ?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!