To define the frequency range when we use FFT
16 ビュー (過去 30 日間)
古いコメントを表示
In my code, I've solved a differential equation numerically, now the goal is to use FFT and plot it in order to find the phase frequency of the original equation. I dont know how to define the frequency intervall to plot the Fourier transform of the equation.
clc
clear all
V0=5; b=0.1;
zc=1; k=1; z0=31; Q=10; Om=6;
Z0=(z0-zc)/zc;
v0=4*b*V0/(k*zc*zc);
f=@(t,y) [y(2) -y(1)+Z0-(y(2)/(Q))+v0*(exp(-4*b*y(1))-exp(-2*b*y(1)))+2*cos(Om*t)]';
y0=[0 0];
t=[0 300];
[T,Y]=ode45(f,t,y0,odeset('RelTol',1e-10));
plot(T,Y(:,1),'b')
grid on
xlabel('Time')
ylabel('Amplitude')
F=fft(Y(:,1)/length(Y(:,1)));
F=abs(F);
fq=1./T;
figure
plot(fq,F)
grid on
But I'm sure my fq is not correct! How should I define it ?!
0 件のコメント
採用された回答
Star Strider
2021 年 4 月 12 日
First, change ‘t’ to:
t=linspace(0, 300, 600); % Needs To Be Regularly-Spaced
then for a two-sided Fourier transform:
Ts = mean(diff(T));
Fs = 1/Ts;
Fn = Fs/2;
Fv2 = linspace(-Fn, Fn, numel(T));
figure
plot(Fv2, fftshift(F))
grid
or for a one-sided Fourier transform:
Fv = linspace(0, 1, fix(size(Y,1)/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, F(Iv))
grid
.
4 件のコメント
Star Strider
2021 年 4 月 13 日
I assume you mean ‘Fv’.
That is the frequency vector for the one-sided fft. The ‘Iv’ vector are the matching indices into ‘F’. (The ‘Fv2’ vector is the frequency vector for the two-sided fft plot. It does not need an index vector.)
その他の回答 (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!