MATLAB: Magnitude scaling in FFT and Periodogram

fftfft scalingperiodogram

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

Best Answer

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