Quantcast
Channel: The Fugue » fft
Viewing all articles
Browse latest Browse all 3

DFT Magnitude/Power Spectra

$
0
0

I often get confused about the scaling of magnitude and power spectra. I think I've worked it out so I'm puttin it here for my own benefit, and maybe the benefit of someone on the internet. If I'm wrong, please tell me.

Let's take a unit-amplitude sinusoid at 100 Hz, and do a Fourier transform. If we look at the amplitude we'd get two components at 100 Hz and -100 Hz, each with amplitude 1/2. Something like this.

Now, if we do the same with a DFT we will get basically the same thing, except we'll see the effects of discretization of course. But depending on which variation of the DFT you're using, the magnitude of the components will be either about 1/2 or about N/2. The difference is, of course, the 1/N factor that you included or left out. In the case of the fft function in Octave (and I assume MATLAB), it's without the 1/N factor.
max(abs(fft(x,1024)))
ans = 443.23

The power spectrum is the magnitude spectrum squared. abs(fft(x)).^2 or (abs(fft(x))/N).^2. Why would you want to square it? Well there are of course many reasons but the nature of audio signals makes most of the ones I know about moot. Furthermore the relative shape of the power spectrum and the magnitude spectrum is the same.

Try this. Take an audio signal (something more interesting than a single sinusoid) and plot the magnitude spectrum in dB, then plot the power spectrum also in dB, e.g.
plot(20*log10(abs(fft(x))))
figure
plot(20*log10(abs(fft(x)).^2))

They have a different scale, but they have the same shape. If you were doing something like peak-picking, it wouldn't matter which you used if you're working in dB.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images