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 CenterFile Exchange에서 Discrete 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