MATLAB Answers

How do I get excatly the same peak amplitude versus frequency when performing FFT?

13 views (last 30 days)
I wish to perform an FFT and plot the frequency on the x-axis and the real amplitude on the y-axis. The data can be downloaded here:
I am using the following MATLAB code:
Fs =1000; % Sample Frequency
ti = 0:0.001:15;
ti= ti';
data = signal;
N = length(data);
freq = 0:Fs/N:Fs/2-Fs/N;
freq = freq';
amplitude = abs(Y(1:floor(N/2)))/floor(N/2);
title ('Time domain signal')
grid on
subplot (212)
xlabel('Frequency [Hz]');
ylabel ('Amplitude');
title('Amplitude Spectrum')
grid on
when executed the code this is what I've got
from the time domain the max peak was in 39.42 mm/s at time 1.248, and then the amplitude goes down and stable with average in 14 mm/s at the rest of the time. I Thought it will give me two spikes at frequency domain with exactly the same amplitude in y-axis which is given above
Why I didn't get the spectrum signal as I wanted, Can someone please help me? Thanks.

Accepted Answer

David Goodmanson
David Goodmanson on 23 Nov 2016
Hi Bagus, There are a couple of things going on here. First, you are plotting out only one half of the frequency array, so you only see one peak, the positive frequency one. Amplitudes are determined by dividing the fft result by N. You are dividing by (N/2) instead which doubles the size of the positive frequency peak. You end up with one peak instead of two, but of twice the height. That's all right when you fft a real function since in that case the pos and neg frequency peaks are the same size**. It would definitely not be all right if you were to fft a complex function.
As for the height of the pulse, it's less than 14 because the duty cycle of the wave is less than the full 15 sec. It looks to be about 90%, so a peak of 12.5 or so is about right.
**they are complex conjugates so same absolute value, not the same phase angle.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by