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

13 views (last 30 days)
Bagus Mahartana on 22 Nov 2016
Answered: David Goodmanson on 23 Nov 2016
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: https://drive.google.com/open?id=0B21C655TFYWJSVFjY1VPeVg0WHM
I am using the following MATLAB code:
Fs =1000; % Sample Frequency
ti = 0:0.001:15;
ti= ti';
data = signal;
N = length(data);
Y(1)=0;
Y=fft(signal);
freq = 0:Fs/N:Fs/2-Fs/N;
freq = freq';
amplitude = abs(Y(1:floor(N/2)))/floor(N/2);
subplot(211)
plot(ti,data)
xlabel('Time[s]')
ylabel('Amplitude')
title ('Time domain signal')
grid on
subplot (212)
plot(freq,amplitude);
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

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.