Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Geeting phase of simple sin wave using FFT

1 visualizzazione (ultimi 30 giorni)
Nina
Nina il 15 Gen 2013
Chiuso: MATLAB Answer Bot il 20 Ago 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

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by