Problem with phase in FFT analysis
古いコメントを表示
I have such problem. I am generating signal which is sinusoid with given parameters (such as amplitude, frequency and phase). Next I am calculating amplitude spectrum and phase spectrum in this way:
fs=1000; %sampling frequency
t=0:1/fs:1; %time
A=1; %amplitude
f=100; %frequency
fi=30*pi/180; %phase (calculated form deg. to rad.)
x = A*cos(2*pi*f*t+fi); %signal
X=fft(x); %FFT
df=fs/length(X); %frequency resolution
f=(0:1:length(X)/2)*df; %frequency axis
subplot(2,1,1);
M=abs(X)/length(x)*2; %amplitude spectrum
plot(f,M(1:length(f)));
subplot(2,1,2);
P=angle(X)*180/pi; %phase spectrum (in deg.)
plot(f,P(1:length(f)));
With amplitude spectrum is everything OK (for frequency 100Hz I have peak equal to 1 what is equal to amplitude) but phase spectrum is not OK (for 100Hz I have 50 deg). Please tell me if my code is OK or maybe I am not interpreting result in right way or maybe I should make some correction of phase results (as thought in case of amplitude spectrum). What is interesting the value of phase is changing due to change of signal frequency or signal sampling what in theory should not happened.
Regards
1 件のコメント
Walter Roberson
2011 年 2 月 10 日
It might make a bit of difference to use
t = linspace(0,1,fs+1);
to avoid accumulated round-off errors that 0:1/fs:1 would have.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!