Magnitude scaling in FFT and Periodogram
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Wayne King
am 15 Sep. 2011
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
Weitere Antworten (2)
Wayne King
am 15 Sep. 2011
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
am 15 Sep. 2011
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 Kommentare
Siehe auch
Kategorien
Mehr zu Spectral Estimation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!