フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Geeting phase of simple sin wave using FFT

1 回表示 (過去 30 日間)
Nina
Nina 2013 年 1 月 15 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by