Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Geeting phase of simple sin wave using FFT

1 vue (au cours des 30 derniers jours)
Nina
Nina le 15 Jan 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hi everyone, first thanks a lot in advance. Second, I am brand new to using FFT thus please forgive my basic questions.
Say I want to make sure that I am getting the correct phase angle of a wave after I apply fft, this how I did it but I am getting the wrong answer:
fs = 10;
t = 0:1/fs:50-1/fs;
x1 = sin(2*pi*t);
m = length(x1); % Window length
n = pow2(nextpow2(m)); % Transform length
y1 = fft(x1,n);
FT_power1 = abs(y1(1:floor(n/2))).^2;
FT_phase1= (unwrap(angle(y1(1:floor(n/2))))) * 180/pi;
[c1,i1] = max(FT_power1);
phase(1) = FT_phase1(i1);
The answer I get is:
305.156
Shouldn't I get 0 or 360 ... What am I doing wrong? how can I make sure I am correctly extracting the phase angle?
PS: I have found this question in an old post, I tried fixing it but to no avail.
Thank you!
PS: It seems like when I remove the unwrap function, I get the correct result: -90 Which is understandable since sin add a pi/2 lag automatically. Is this a coincidence? I don't really understand what the unwrap function does? I found info saying that it removes the multiple of pi and another info saying that it adds pi, but I am unsure... Thanks

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by