How to get amplitude of the signal from FFT results?

18 views (last 30 days)
Hi all
I have a response signal (in picture, it's uniform) with amplitude of 13.6656. I calculate amplitude from time series by taking half of the difference of maximum and minimum value of single signal. But when I make fft and get absolute value of it I cannot get this amplitude. My code is this:
y=fft(prediction)/length(prediction)
amp=2*abs(y)
The value coming from that code is 8.7330.
Thank you in advance.
  2 Comments
dpb
dpb on 11 May 2018
The two aren't necessarily ever going to be the same unless the signal is uniform single frequency; the FFT spectrum is spread over all energy frequencies in the signal; your amplitude calculation in time domain is for the entire time signal; you can't isolate the contributions versus frequency from it.
The example at
doc fft
illustrates the normalization matches the exact time series amplitude for a given frequency; you can experiment with the examples there to see the difference between that amplitude and the max/min in the time domain.
Murat Yetkin
Murat Yetkin on 12 May 2018
Thank you for answer. My signal is uniform. I added screen shot of signal plot. I read the fft help in Matlab but it did not help me.

Sign in to comment.

Answers (2)

dpb
dpb on 12 May 2018
Edited: dpb on 13 May 2018
Had a fairly protracted discussion on subject recently here <Answer 315674> There are a couple nuances besides; one being there is only one DC and Fmax component in the 2-sided DFT returned when compute just the one-sided plus a single frequency bin will match the peak exactly only if the sampling frequency is exact multiple; otherwise the energy will be spread over the bins nearest and will have to integrate to match...
ADDENDUM Add to the example; duplicate the example in the doc keeping sampling rate, etc., the same except instead of two frequencies 50, 120 Hz in signal that are identically in the frequency vector 0:df:Fmax, let's pick 51 Hz and 119 Hz that don't match precisely; essentially the case almost always in real world...
All is the same excepting we define
S = 0.7*sin(2*pi*51*t) + sin(2*pi*119*t);
X = S + 2*randn(size(t));
and then duplicate from there. The result is
and voila!!! we don't have peaks of 0.7, 1.0 exactly and the noise floor is much more obvious when compare to the example that does match...let's see what we actually got--
>> [pk,loc]=findpeaks(P1,'NPeaks',2,'MinPeakHeight',0.25)
pk =
0.3760 0.7477
loc =
78 179
>> f(loc)
ans =
51.3333 118.6667
>>
ADDENDUM 2
Realized that the difference is more clearly seen if don't use the noise...same two cases without noise, notice the frequency spreading when the result of the sampling rate/time generates a frequency binning that doesn't match precisely the frequency of the tones in even a noise-free signal.
(The titles say w/ Noise but that's an oversight in forgot to edit to include "w/o" and too much trouble to regenerate just to make the minor fix...)

possibility
possibility on 12 May 2018
Mostly, length of your signal in time domain is not equal to the length of its fft. From Parseval Theorem, their powers are equal, but the amplitudes don't have to be.
So, what you're asking is not meaningful. If you still want to know the amplitude, try dividing it by the correct length, i.e. length(fft(prediction))

Tags

Products

Community Treasure Hunt

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

Start Hunting!