How can i determine phase in FFT?
Afficher commentaires plus anciens
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 commentaires
Dan Bullard
le 18 Mar 2023
I use this constantly in Excel, it's atan2(real, imaginary)
With this I proved Bullard Laws of Harmonics #5,
http://www.danbullard.com/dan/articles/why_law_5_is_so_important/why_law_5_is_so_important.html
Star Strider
le 18 Mar 2023
Bruno Luong
le 19 Mar 2023
Modifié(e) : Bruno Luong
le 19 Mar 2023
@Dan Bullard "it's atan2(real, imaginary)"
That formula is wrong the right formula is atan2(imaginary, real) and this is exactly what angle function does.
So reverse the two atan2 arguments, then you will fix the "backwardness" of your formula.
Dan Bullard
le 19 Mar 2023
arctan2 is different in Fortran and Excel, forgive me, I use Excel and didn't know about the angle() function.
WH Wang
le 28 Juin 2023
it's atan2(imaginary,real) in matlab, or using phase() function of matlab.
Star Strider
le 28 Juin 2023
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.
Réponse acceptée
Plus de réponses (1)
karinkan
le 1 Juin 2018
0 votes
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;
1 commentaire
Star Strider
le 1 Juin 2018
The first one.
Catégories
En savoir plus sur Digital Filter Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
