Code to Set the Number of Spectral Lines of an FFT(Freq Resolution)
古いコメントを表示
Hi
I'm quite new to MATLAB. I'm working on spectral analysis of a signal and trying to obtain its FFT. But the problem is that my spectral lines are coming out to be quite braod and eventually, data analysis is not possible. I'm using the following code for the obtaining the FFT:
M = 2.5e-4; Fs = 1/M; T = 1/Fs; L=1000000; NFFT = 2^nextpow2(L); Y = fft(ias, NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); plot(f,2*abs(Y(1:NFFT/2+1)))
https://docs.google.com/leaf?id=0B4dPcFFHHl9VZGM3ZmJiMWItYzAyMy00YjAxLWFhOWUtYTA3YjRiNTI3ODE4&hl=en_US Kindly suggest some solution for this problem.
Thanks and Regards.
回答 (1 件)
Honglei Chen
2011 年 7 月 6 日
0 投票
Hi Anshul,
I think there are two things you need to consider:
1. To get the perfect spectral line for your 60 Hz signal, you need to have a frequency sample at exact 60 Hz. Unfortunately, 60 Hz is not a multiple of your frequency resolution, i.e., Fs/NFFT, so you will not get the perfect spectral line in your spectrum.
2. Even if the condition in 1 is satisfied, if you use plot(), MATLAB automatically do the interpolation between points. So you will still see a triangle at 60 Hz. If you really really want to just see a line, you can use stem() instead.
HTH.
2 件のコメント
Anshul
2011 年 7 月 6 日
Honglei Chen
2011 年 7 月 6 日
What do you mean by "it did not work"? You get an error or you don't see the perfect line? Does your code satisfy the first condition? Try to set NFFT=L and you should be able to see the spectral line. Of course I'm assuming you have a perfect 60 Hz signal ias, e.g., ias = sin(2*pi*60*(0:L-1)*T)
カテゴリ
ヘルプ センター および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!