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

2 ビュー (過去 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 Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by