How can i determine phase in FFT?

조회 수: 466 (최근 30일)
Big dream
Big dream 2016년 10월 24일
댓글: Star Strider 2023년 6월 28일
Hi everyone, right now im trying to calculate signal phases using angle(x) from FFT Function im Matlab. Noted that i've coded the program like below :
%%Plotting Grafik
%create a time vector 't', containing integers from 1 to n(summary of data)
count= length(data);
Ts=mean(diff(times1));
Fs=1/Ts;
NFFT=2^nextpow2(count);
y=fft(data,NFFT)/count;
f=Fs/2*linspace(0,1,NFFT/2+1);
figure(2)
plot(f,2*abs(y(1:NFFT/2+1)));
grid on
title('Single-Sided Amplitude Spectrum of y(t)');
xlabel('Frequency(Hz)');
ylabel('|Y(f)|');
phase=angle(y);
But i'm not really sure with the phase function. Does anyone ever has the same experience?
Thanks before for your answer.
  댓글 수: 6
WH Wang
WH Wang 2023년 6월 28일
it's atan2(imaginary,real) in matlab, or using phase() function of matlab.
Star Strider
Star Strider 2023년 6월 28일
There is no phase function that I can find in the documentation, however there is the angle function that returns the phase angle (in radians) of a complex argument.

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

채택된 답변

Star Strider
Star Strider 2016년 10월 24일
편집: Star Strider 2016년 10월 24일
Your code appears to me to be correct, including the ‘phase’ assignment. Note that the units of ‘phase’ are in radians. Convert them to degrees (if desired) by multiplying them by 180/pi.
I’m not certain what you want, so also consider the unwrap function. Use it on the radian units, and convert to degrees later if necessary.
EDIT If you want to plot it, the easiest way is to use the subplot function. Your plotting code changes to:
phase=angle(y);
figure(2)
subplot(2,1,1)
plot(f,2*abs(y(1:NFFT/2+1)));
grid on
title('Single-Sided Spectrum of y(t)');
ylabel('|Y(f)|');
subplot(2,1,2)
plot(f,phase)
grid on
xlabel('Frequency(Hz)');
ylabel('Phase (rad)')
I did not test that, but it should work.
  댓글 수: 14
Big dream
Big dream 2016년 12월 6일
thanks again for your advice.^^
Star Strider
Star Strider 2016년 12월 6일
My pleasure.

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

추가 답변 (1개)

karinkan
karinkan 2018년 6월 1일
I am a bit confusing that the following two equations which one is correct? eq.1 y=fft(data,NFFT)/count; eq.2 y=fft(data,NFFT)/NFFT;

카테고리

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