MATLAB Answers

amplitude of (signal) after FFT operation?

1,186 views (last 30 days)
Mary Jon
Mary Jon on 15 Nov 2014
Commented: Matty Lu on 3 Sep 2017
I have this code, I am suppose sin of amplitude 10 with frequency 200hz and sampling frequency 20000 hz and do FFT on this signal,
why the Amplitude after FFT is 1000?? where the amplitude must be stay 10
Fs = 20000;
t = 0:1/Fs:0.01;
fc1=200;
x = 10*sin(pi*fc1*t)
x=x';
xFFT = abs(fft(x));
xDFT_psd = abs(fft(x).^2);

  1 Comment

Ait m'barek Soufiane
Ait m'barek Soufiane on 2 Aug 2017
Hi.. I have the same qst, did you find the answer?

Sign in to comment.

Accepted Answer

Matt
Matt on 15 Nov 2014
Edited: Matt on 17 Nov 2014
Mary,
In general, to return a FFT amplitude equal to the amplitude signal which you input to the FFT, you need to normalize FFTs by the number of sample points you're inputting to the FFT.
Fs = 20000;
t = 0:1/Fs:0.01;
fc1=200;
x = 10*sin(pi*fc1*t)
x=x';
xFFT = abs(fft(x))/length(x);
xDFT_psd = abs(fft(x).^2);
Note that doing this will divide the power between the positive and negative sides, so if you are only going to look at one side of the FFT, you can multiply the xFFT by 2, and you'll get the magnitude of 10 that you're expecting.
The fft documentation has a pretty good example that illustrates this and some other fft best practices.
*Edited for clarity, - see Matt J's comment for the original statement.

  6 Comments

Show 3 older comments
Mary Jon
Mary Jon on 16 Nov 2014
how can I scale by time sampling interval please
Matt J
Matt J on 17 Nov 2014
As follows, but it doesn't sound like that is the type of scaling your situation requires,
deltaT=1/Fs; %time sampling interval
xFFT = abs(fft(x)*deltaT);

Sign in to comment.

More Answers (1)

Matt J
Matt J on 16 Nov 2014
Edited: Matt J on 16 Nov 2014
You also have to be careful about how you design your frequency space sampling. In your current code, the frequency sampling interval is Fs/length(t)=99.5025 Hz. But the frequency you are trying to sample is at 100 Hz, so your Fourier Space sampling will never hit this. And, because the spectrum is sharply peaked, you can get significant errors with this deviation.

  3 Comments

Mary Jon
Mary Jon on 16 Nov 2014
I need only calculate fft and PSD of sin wave with frequency 200hz and sampling frequency 20000hz,
this code represent as a test on well known signal (sin) to help me how do this (FFT) in signals of my project
Matt J
Matt J on 16 Nov 2014
The signal you've shown is 100 Hz. A 200 Hz sinewave would have fc1=400.
But I'm not sure you caught my point. The amplitude of the FFT result will depend not only on the sampling frequency Fs, but also the number of samples length(x). Below, for example, we see that the peak amplitude of xFFT is not really exactly 1000 until you drop one sample:
>> max( abs( fft(x) ) )
ans =
1.0023e+03
>> max( abs( fft(x(1:end-1)) ) )
ans =
1000
Mary Jon
Mary Jon on 26 Nov 2014
ok, matt the x-axis represent numbers of sample (201)isnt it,How can I (modify in code) to made x axis of xFFT in frequency unit? please

Sign in to comment.

Tags

Products

Community Treasure Hunt

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

Start Hunting!