Magnitude scaling in FFT and Periodogram
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi all, I am trying to use to matlab(with signal processing tool box option) to look at FFT of sin waves.
It looks the fft function does not output magnitude correctly without a few more lines of code.
The code for scaling the fft correctly for DC and all frequency bins is given in the link below
Is there similar code for scaling the magnitude's when using the periodogram function ?
I understand the code listed in the link above essentially does the function of periodogram. But there is more is more than one reason why scaling the periodogram function similarly would be very helpful.
regards
SRS
댓글 수: 0
채택된 답변
Wayne King
2011년 9월 15일
Hi, If you are using the Signal Processing Toolbox, then the correct scaling is built into the periodogram function and the spectrum.periodogram object.
Fs = 1e3;
t = 0:1/Fs:1-1/Fs;
x = cos(2*pi*100*t)+randn(size(t));
plot(psd(spectrum.periodogram,x,'Fs',1e3,'NFFT',length(x)))
To produce the correct scaling for a one-sided periodogram with known sampling frequency using the DFT, you would have to enter:
xdft = fft(x);
psdx = 1/(length(x)*Fs).*abs(xdft(1:length(x)/2+1)).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
figure;
plot(10*log10(psdx)); grid on; axis tight;
Whether it is important for you to get the scaling theoretically correct really depends on what you are using the periodogram for and how you are using it.
Wayne
추가 답변 (2개)
Wayne King
2011년 9월 15일
Hi, bin 101 is not equivalent to 101 Hz. The bins are spaced in 1 Hz increments in this case, but you are forgetting that the first bin is DC, zero frequency.
Wayne
Wayne King
2011년 9월 15일
psdest = psd(spectrum.periodogram,x,'Fs',1e3,'NFFT',length(x));
psdest.Data
has the periodogram values (not in dB),
psdest.Frequencies
has the frequencies.
The plot() method knows how to act on this object, so
plot(psdest)
produces a plot in dB.
Wayne
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Estimation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!