Why is FFT result divided by NFFT instead of the root of NFFT?

9 vues (au cours des 30 derniers jours)
Miktat Vural
Miktat Vural le 11 Avr 2023
Modifié(e) : Paul le 24 Avr 2023
Hi everyone,
yfft = fft(y)
According to parvela's theorem, the equation below must be achieved.
sum(y.^2) == sum(abs(yfft).^2/length(yfft))
On both sides of the equation, actually, the power values are summed, right?.
So why is yfft divided by length of yfft to find the amplitude spectrum in the MATLAB FFT example? Shouldn't it be divided by the root of yfft length to ensure the equation?
Do I think wrong? If you could enlighten me on this matter, I would appreciate it.

Réponse acceptée

Paul le 13 Avr 2023
Modifié(e) : Paul le 24 Avr 2023
Hi Miktat,
The energy spectrum and the amplitude spectrum are two different things. Using the conventions of fft, the output yfft is divided by numel(y) so as to match the amplitude of the complex sinusoids that make up the underlying signal.
For example, define a finite duration signal as the sum of two complex sinusoids
n = 0:99;
y = 1.5*exp(1j*2*pi*.3*n) + 3*exp(1j*2*pi*.7*n);
Compute the FFT
Y = fft(y);
Plot the result in the frequency domain, dividing by numel(Y)
N = numel(y);
We see that dividing the FFT, as defined in fft, by N yields the amplitude spectrum in the frequency domain with peaks at the same amplitudes as the constituent complex sinusoids.
You are, of course, correct that we can compute the energy in the signal in either domain
format long e
[sum(y.*conj(y)) sum(Y.*conj(Y))/N]
ans = 1×2
1.0e+00 * 1.125000000000000e+03 1.125000000000000e+03
We can plot the energy spectrum if that's what's desired
with the understanding that the spectrum is to be summed to get the energy in the signal.
If we zero pad the FFT, then, as @dpb pointed out, we still divide by the length of the time domain signal to get the proper amplitude (not the length of the FFT)
Y = fft(y,1024);
Nfft = numel(Y);
The peaks at 0.3 and 0.7 are still very close to the amplitudes of the complex sinusoids; the rest of the non-zero elements are filling in the true amplitude spectrum of the windowed signal.
However, the energy computation uses the length of the fft, i.e., Nfft
[sum(y.*conj(y)) sum(Y.*conj(Y))/Nfft]
ans = 1×2
1.0e+00 * 1.125000000000000e+03 1.124999999999999e+03
So you'd have to scale by Nfft if wanting to plot the energy spectrum after zero padding.
  1 commentaire
Miktat Vural
Miktat Vural le 24 Avr 2023
Thanks for your explanation. I guess I confused energy spectrum with amplitude spectrum.

Connectez-vous pour commenter.

Plus de réponses (1)

dpb le 11 Avr 2023
Modifié(e) : dpb le 11 Avr 2023
Well, let's try it and see...
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T;
S = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
X = S + 2*randn(size(t));
Y = fft(X);
ans = logical
ans = 9.0949e-13
shows it is equal to almost the double-precision.
NOTA BENE: Remember that if pad the signal so that NFFT is >L, the divisor is still L, NOT NFFT since there's no power in the zero-padded elements.
  1 commentaire
Miktat Vural
Miktat Vural le 24 Avr 2023
Thanks for your explanation.

Connectez-vous pour commenter.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by