relation between fft and rms

I'd like to clarify a fundamental issue: what is the relation between fft of a function and its rms value?
Following Matlab example of computing fft of a function:
%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
...
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1)))
...
%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
what is the relation between 2*abs(Y(1:NFFT/2+1)) and rms(Y)?
Many thanks.

 Accepted Answer

Star Strider
Star Strider on 27 May 2014
Edited: Star Strider on 27 May 2014
The fft is the (fast) Fourier transform of a signal. It transforms it from a time-comain signal (signal amplitude as a function of time) to a frequency-domain signal, expressing the amplitudes of various components in the signal with respect to their frequencies.
the RMS (root mean squared) value of a signal is a way of expressing its average (mean) power. It is the square root of the mean of the squared value of the signal. For simusiodal signals, the RMS value is 0.707 times the peak-to-peak amplitude of the signal.
For a signal vector s:
RMS = sqrt(mean(x.^2));
The total energy of a signal is preserved under the Fourier transform ( Parseval's theorem ), so the sum (or integral) of the square of a function is equal to the sum (or integral) of the square of its transform. The RMS would be the square root of that value.

2 Comments

Thank you Star.
My pleasure!

Sign in to comment.

More Answers (2)

Matt J
Matt J on 27 May 2014
Edited: Matt J on 28 May 2014
For brevity, I define the half-spectrum as
Z=2*abs(Y(1:NFFT/2+1));
I think it helps to start with the identity
rms(Y)= sqrt(sum(abs(Y.^2)))/sqrt(NFFT)
For real-valued initial signal, y, the spectrum Y would be conjugate symmetric and so it would be approximately, but not exactly, true that
sum(abs(Y.^2)) = 2*sum( abs(Y(1:NFFT/2+1)).^2)
= sum(Z.^2)/2
It would be exact if the DC component Y(1) is zero.
Combining the above equations therefore leads to the approximation
rms(Y)= sqrt(sum(Z.^2))/(sqrt(2*NFFT));
EDIT:
Sorry, I just noticed that the above relation is true when NFFT is odd. When it is even, the relation is more complicated. When NFFT is odd, it is easy to verify the above relationship, though:
>> NFFT=31; Y=abs(fft(rand(1,NFFT))); Y(1)=0; Z=2*Y(1:ceil(NFFT/2));
>> rms(Y), sqrt(sum(Z.^2))/(sqrt(2*NFFT))
ans =
1.4291
ans =
1.4291

4 Comments

Thank you Matt. What about the relation to rms(y)?
According to Parseval's theorem, rms(y) should equal sqrt(sum(Y(1:NFFT/2+1).^2)), (Y is after /L), is it right? However I tested a signal and there always about 20% difference between the two. What is the problem?
The fft is not windowed and the DC component is 0.
Matt J
Matt J on 28 May 2014
Edited: Matt J on 28 May 2014
If length(y)=NFFT, then the relationship between rms(y) and rms(Y) is
rms(Y)=rms(y)/sqrt(NFFT)
This is true whether NFFT is odd or even and is readily verifiable by examples,
>> y=rand(1,10); Y=fft(y)/10; rms(y)/sqrt(10), rms(abs(Y))
ans =
0.1852
ans =
0.1852
The relationship to the half spectrum then follows from my original answer above. If length(y)<NFFT, then things are more complicated.
Thanks for your explanation
Hello Matt,
hope you are doing well. Based on your example/explanation that means that rms(Y)=/rms(y), right? Meaning that the RMS of the time domain gives a different value as the RMS of the frequency domain. Only with a difference of 1/sqrt(NFFT) though but still.
Then why are people trying to show that, rms(Y)=rms(y) because of the Parseval's theorem?
Thank you very much in advance.

Sign in to comment.

Hello, I got the case that length(y)<NFFT, how would be the relation? Actually I'm getting NFFT as
NFFT = 2^nextpow2(L);
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);

Tags

Asked:

on 27 May 2014

Commented:

Geo
on 10 Mar 2023

Community Treasure Hunt

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

Start Hunting!