Finding Dominant Frequency and Phase using FFT

조회 수: 9 (최근 30일)
Matt Gaidica
Matt Gaidica 2020년 10월 3일
댓글: Bjorn Gustavsson 2020년 10월 4일
This is stemming from a forecasting problem, but my fundamental assumption about FFT appears to be incorrect. Below, I'm generating a pure sinusoid at 5Hz for 5 seconds (top). The amplitude of the FFT (padded, middle) confirms the dominant frequency. However, I'm unclear why phase at 5Hz would not equal 0 using angle() (bottom)? The ultimate goal is to find the dominant frequency and phase of a noisy signal using FFT, then forecast using a pure, phase-shifted sinusoid.
Fs = 125;
plotS = 5;
t = linspace(0,plotS,plotS*Fs);
fmod = 5;
pdelay = 0;
X = sin((2*pi*fmod*t) + pdelay);
close all
ff(800,600);
subplot(311);
plot(t,X);
hold on;
xlabel('Time (s)');
ylabel('Amplitude');
L = numel(t);
nPad = 5;
n = (2^nextpow2(L)) * nPad;
Y = fft(X,n);
f = Fs*(0:(n/2))/n;
P = abs(Y/n).^2;
A = angle(Y);
grid
subplot(312);
plot(f,P(1:n/2+1))
xlabel('Frequency (f)')
ylabel('|P(f)|^2')
xlim([0 10]);
grid
subplot(313);
plot(f,A(1:n/2+1));
xlabel('Frequency (f)')
ylabel('Phase (rad)');
xlim([fmod-2 fmod+2]);
grid

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2020년 10월 4일
Change your function to cos((2*pi*fmod*t) + pdelay) and re-run your code-snippet.
Also check what happens when you reduce your time-axis by one sample.
HTH
  댓글 수: 2
Matt Gaidica
Matt Gaidica 2020년 10월 4일
cos() does the trick! Thanks, Bjorn. I didn't reduce the time-axis, what is your thought behind that? Do you mean something like this right after t is declared?
t = t(1:end-1);
Bjorn Gustavsson
Bjorn Gustavsson 2020년 10월 4일
Yup. I forgot you zero-padded your time-series, if you remove that you will see the difference between a signal that is perfectly periodic over your intervall and one that is not.

댓글을 달려면 로그인하십시오.

추가 답변 (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