Problem using fft();

1 回表示 (過去 30 日間)
atharva aalok
atharva aalok 2021 年 10 月 21 日
コメント済み: atharva aalok 2021 年 10 月 21 日
I have a periodic signal with TimePeriod~2.3 that is f~.4347
But I am getting another peak at f = 0.
load('myData.mat');
figure(1);
plot(tSol, omegaSol);
% This is periodic with TimePeriod~2.3 or f~.4347
Fs = length(tSol) / (max(tSol)-min(tSol)); % Sampling frequency
T = 1/Fs; % Sampling period
L = Fs * (max(tSol) - min(tSol)); % Length of signal
t = (0:L-1)*T; % Time vector
Y = fft(omegaSol);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
limit_f = f < 1;
f = f(limit_f);
P1 = P1(limit_f);
figure(2);
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
Why Is there another peak at f ~ 0?

採用された回答

KSSV
KSSV 2021 年 10 月 21 日
編集済み: KSSV 2021 年 10 月 21 日
Remove the mean from the data and then use fft.
Say A is your data, (array). For fft use:
A = A-mean(A) ;
  1 件のコメント
atharva aalok
atharva aalok 2021 年 10 月 21 日
Yeah lol I just realised a second after posting thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by