How to find fft for a system of two variables? Can you check my code if it is right, please?

3 次查看(过去 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 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by