Obtaining amplitude values from an FFT

104 views (last 30 days)
Hi there, I have made a single-sided spectrum using FFT of a time-domain signal. From that FFT, I would like to somehow get the amplitude at each of the frequencies from the signal.
If I am outputting an FFT that looks like the attached plot, which has about 4 distinct peaks, what should I do with this plot to get amplitude? I got it using
S = fft(eta)
P2 = abs(S/nFFT);
Where nFFT is the number of sampling points and eta is a time-domain signal.

Accepted Answer

Star Strider
Star Strider on 6 Oct 2016
To get the _correct) amplitudes for a one-sided fft, you need to change your code to:
S = fft(eta)/nFFT;
P2 = abs(S)*2;
Then plot ‘P2’.
The reason is that the total energy in the signal is conserved in the total fft, that, because it is symmetric, will have half the energy at the positive frequency and half at the negative. You have to multiply the amplitudes of the one-sided fft by 2 to plot the correct amplitudes.
The units of the Fourier-transformed amplitudes (using the code I changed) are the same units as the original signal.
For a full discussion, see the R2015a documentation for fft (link).
  6 Comments
yusra Ch
yusra Ch on 16 Mar 2020
Hi Star rider,
Could you plz help me with interpreting this FFT figure. this is the Fourier transform of a small scale fading component (comming from not periodic signal). The Y axis is the abs of the normalized amplitude.
dpb
dpb on 17 Mar 2020
"These details relating to bins, etc have been confusing me..."
In particular, note there is only one (1) DC and one (1) Fmax bin so when take the double-sided FFT frequencies, do NOT double those two. The example of a one-sided PSD in the documentation accounts for this but is sadly lacking in a comment as to why the specific subscripting...
P1(2:end-1) = 2*P1(2:end-1);
but that's why the initial "2" and the "end-1" in the above; exclude doubling the energy in those two bins that's already fully accounted for.
Often there's little energy in Fmax if the input signal is, as should be, oversampled and the data collection system uses anti-aliasing filters so doubling it often is undetected and doesn't make any practical difference. OTOH, if there's any DC in the signal and/or the mean isn't subtracted from the signal before FFT, then the DC component can be large and when/if doubled really distort the resulting appearance.
Of course, it's stil just the DC component, but can be confusing and will definitely screw up the overall energy if not properly accounted for.

Sign in to comment.

More Answers (1)

dpb
dpb on 6 Oct 2016
If have Signal Processing toolbox, see
doc findpeaks
Otherwise, peaks cannot be found easily simply by comparing values. Use trend data to identify peak locations. A peak happens when the slope sign changes from +ive to -ive, i.e., a peak is where the difference changed from a streak of positives and/or zeros to negative. In your sample, peaks are quite well defined and not very noisy at all; this won't be terribly difficult.
I'm sure there are some peak-finding routines to be found on File Exchange if you don't have the SP Toolbox that could save some effort but I don't have a direct link at hand.
  2 Comments
dpb
dpb on 6 Oct 2016
[Moved from Answer to Comment--dpb]
Hi dbp,
Thanks for your answer. Ok I've used findpeaks before but then I was confused when using it how to know what the units are or how to output an actual amplitude value. Can you offer any advice on this?
Thanks!
dpb
dpb on 6 Oct 2016
Not sure why the confusion??
>> help findpeaks
findpeaks Find local peaks in data
PKS = findpeaks(X) finds local peaks in the data vector X. ...
[PKS,LOCS]= findpeaks(X) also returns the indices LOCS at which the peaks occur.
...
The value(s) of the peak(s) is(are) the default return; you can also find where to look up frequency from the second index optional return.
The magnitude is dependent upon the units of the signal you passed into fft and how you normalized it.
It is peculiar how you got a one-sided spectrum looking like the attached figure from the code snippet posted; I presumed that was not the actual code but only a partial outline or the figure isn't that you actually have but from some other source???
There's an example in
doc fft
of the normalization and how to get the one-sided PSD from the full 2-sided transform.
A detailed analysis of the relationships is found at <introduction-to-communication-control-and-signal-processing_chap10.pdf>

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!