How to find fft for a system of two variables? Can you check my code if it is right, please?
1 次查看(过去 30 天)
显示 更早的评论
function aaa
b= 3;
[t,x]=ode45(@DoubleSpeciesSystem, 0:0.01:10000 , [30 6] , [] , b);
n = length(x);
h=0.01;
dt = t(end)/(n-1);
Fs=1/dt;
NFFT=n;
y=fft(x,NFFT)/n;
f=linspace(0,1,NFFT/2+1)*(Fs/4);
Pow = abs(y(1:NFFT/2 +1)).^2; % Power of the DFT
Pow(1) = 0;
figure(1) % Plot single-sided amplitude spectrum.
plot(f,Pow)
1;
%function dxdt = DoubleSpeciesSystem(t,x,b)
%x(1) = prey
% x(2) = predator
%dxdt(1) = 15 * x(1) - b * x(1).* x(2);
%dxdt(2) = -5 * x(2) + 0.5 * x(1).* x(2);
%dxdt = [dxdt(1) dxdt(2)]';
%end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!