How can i determine phase in FFT?
Mostrar comentarios más antiguos
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 comentarios
Dan Bullard
el 18 de Mzo. de 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
el 18 de Mzo. de 2023
Bruno Luong
el 19 de Mzo. de 2023
Editada: Bruno Luong
el 19 de Mzo. de 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
el 19 de Mzo. de 2023
arctan2 is different in Fortran and Excel, forgive me, I use Excel and didn't know about the angle() function.
WH Wang
el 28 de Jun. de 2023
it's atan2(imaginary,real) in matlab, or using phase() function of matlab.
Star Strider
el 28 de Jun. de 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.
Respuesta aceptada
Más respuestas (1)
karinkan
el 1 de Jun. de 2018
0 votos
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 comentario
Star Strider
el 1 de Jun. de 2018
The first one.
Categorías
Más información sobre Digital Filter Analysis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
