# Amplitude of the Signal in Frequency Domain different from Time Domain

How does the Amplitude of the Signal is changed when taking the FFT of a Signal,

Have a look,

The amplitude had changed from 2 to 30, and Here is my code for generating the above output,

f=1e3;   %Frequency of Wave
A=2;    %Amplitude
Fs = 1e6;  %Sampling Frequency

Ts = 1/Fs;   %Sampling Rate

t = 10/f;       %Time period of 1 Oscillation = 1/f

n = 0:Ts:t;  %Generating Samples

x=A*sin(2*pi*f*n);
subplot(2,1 ,1)
plot(x

% 100,000 = Fs
% 10,000 = Length of the Signal
% 100,000/10,000 = 100Hz <- First point in FFT = 100Hz
% 2nd Point = 200Hz
% 3rd Point = 300Hz
% 4th Point = 400Hz
% .
% .
% 10th Point = 1KHz <- Original Signal Frequency

subplot(2,1 ,2)
F=fft(x);
plot(real((F))),grid on
xlim ([0 20])


You're overlooking four things:

• The $\frac{1}{FFT\_size}$ normalization coefficient. Some FFT implementations have or do not have this factor. Check the definition of FFT as performed by matlab on the Mathworks site!
• Why are you looking at the real part only? The amplitude is conveyed by the modulus (magnitude) of the complex number. Here, the real part is 31 but the imaginary part is -10000.
• A sine wave of amplitude 2 yields two complex exponentials of magnitude 1.
• Keep in mind that you are not computing the Fourier transform of a sine wave (which goes from minus infinity to infinity), but of a sine waved multiplied by a rectangular window. As a result, you won't find the spectrum of a sine wave, but the spectrum of a sine wave convolved by the spectrum of your aperture (a sinc function for the rectangular window). The energy will bleed over adjacent frequency bins instead of being confined in bin 11. You will need to sum the energy over the adjacent bins to recover all the energy!

abs(F(11)) is 10000. Divide by the sample length and you get a bit less than one (which is the expected value). Sum the small residues across the adjacent bins and you'll get back your expected energy.

• In case it's not clear in my answer, you also have an off by one error (your sample length is 10001 points). – pichenettes Sep 27 '12 at 17:30
• i couldn't get you, can you please explain with the little bit for sample code ? – Sufiyan Ghori Sep 27 '12 at 17:30
• SO I know when we take the FFT of the signal we get both Real/Imaginary parts and Imaginary part is nothing but the past values, here i have plotted only the real part , do i need to sum both real and imaginary before plotting it ? also there is no just one spike , there is another spike same as this one , however the x-lim obselete it – Sufiyan Ghori Sep 27 '12 at 17:40
• @Efected: Here's sample code for Python, showing how you use abs() to get the magnitude, and divide by N to normalize the amplitude, and line up the sinusoid perfectly so there's no bin leakage: gist.github.com/236567 Guess I could add the same for Octave/Matlab. – endolith Sep 27 '12 at 17:43
• @Efected: I don't understand what you mean by "imaginary part is nothing but the past values". You're probably misunderstanding. The real and imaginary parts encode the phase and amplitude. You can convert them to phase and magnitude parts instead. Generally you want the magnitude. – endolith Sep 27 '12 at 17:49

Here is how you should do it.

The two spikes in the FFT will have an amplitude of 1 each (sum those and you get the time domain amplitude of 2)

clc
close all
clear all

f = 1000;
A = 2;
Fs = 16000;
t = 0:1/Fs:100/f;
x=A*sin(2*pi*f*t);
subplot(2,1 ,1)
plot(x)

% 100,000 = Fs
% 10,000 = Length of the Signal
% 100,000/10,000 = 100Hz <- First point in FFT = 100Hz
% 2nd Point = 200Hz
% 3rd Point = 300Hz
% 4th Point = 400Hz
% .
% .
% 10th Point = 1KHz <- Original Signal Frequency

subplot(2,1 ,2)
plot(abs(fft(x))./length(x))

• then what is that value 30 on y-axis ? – Sufiyan Ghori Sep 27 '12 at 17:22
• Your calculation was wrong to begin with. So 30 is also wrong. – DspGuru Sep 28 '12 at 17:02