relation between fft and rms

352 views (last 30 days)
Lian
Lian on 27 May 2014
Commented: Geo on 10 Mar 2023
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.

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
Big dream
Big dream on 11 Nov 2016
Thanks for your explanation
Geo
Geo on 10 Mar 2023
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.


Adrian Sanz
Adrian Sanz on 17 Apr 2017
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

Community Treasure Hunt

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

Start Hunting!