amplitude of (signal) after FFT operation?

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);

 채택된 답변

Matt
Matt 2014년 11월 15일
편집: Matt 2014년 11월 17일

6 개 추천

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.

댓글 수: 8

ok, 1.can I said my code true or not ? because my teacher said this not true!
2.and can I do this in PSD?
xDFT_psd = abs(fft(x).^2)/length(x);
3.what time in x-axis, sec ?
Matt
Matt 2014년 11월 15일
1. I'd certainly defer to your teacher in that. If this is homework, I don't know what the objective is, and I suggest you continue to work with your teacher.
2. Hint: You have to be careful with your order of operations.
3. Look at the example in the fft documentation, and possibly run through it.
Matt J
Matt J 2014년 11월 16일
In general you need to normalize FFTs by the number of points you're inputting to the FFT.
That's true if the FFT is being used to compute Fourier Series coefficients. If the idea is to approximate a continuous Fourier Transform integral, the FFT needs to be scaled by the time sampling interval 1/Fs. If the idea is to preserve signal energy (Pareseval's theorem), the FFT needs to be normalized by 1/sqrt(N).
Mary Jon
Mary Jon 2014년 11월 16일
how can I scale by time sampling interval please
Matt J
Matt J 2014년 11월 17일
편집: Matt J 2014년 11월 17일
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);
Matty Lu
Matty Lu 2017년 9월 3일

Thanks Mary! Epic!

632541
632541 2021년 4월 21일
Hi Matt J,
That's true if the FFT is being used to compute Fourier Series coefficients. If the idea is to approximate a continuous Fourier Transform integral, the FFT needs to be scaled by the time sampling interval 1/Fs. If the idea is to preserve signal energy (Pareseval's theorem), the FFT needs to be normalized by 1/sqrt(N).
How do I decide which one to use ?
Guanjiang Chen
Guanjiang Chen 2021년 5월 11일
Could anyone please tell me what 'a FFT amplitude equal to the amplitude signal which you input to the FFT' mean? What is the amplitude of signal I input? which set will affects the amplitude of input signal? the sample number or the sample frequency?

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Matt J
Matt J 2014년 11월 16일
편집: Matt J 2014년 11월 16일

1 개 추천

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.

댓글 수: 6

Mary Jon
Mary Jon 2014년 11월 16일
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 2014년 11월 16일
편집: Matt J 2014년 11월 16일
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 2014년 11월 26일
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
632541
632541 2021년 4월 21일
Hi Matt J,
That's true if the FFT is being used to compute Fourier Series coefficients. If the idea is to approximate a continuous Fourier Transform integral, the FFT needs to be scaled by the time sampling interval 1/Fs. If the idea is to preserve signal energy (Pareseval's theorem), the FFT needs to be normalized by 1/sqrt(N).
How do I decide which one to use ?
Matt J
Matt J 2021년 4월 21일
@Kaveri A I think you've answered your own question. If your application expects discrete-space signal energy to be preserved, normalize by 1/sqrt(N).
632541
632541 2021년 4월 23일
@Matt J My signal is taken from sensor with sampling frequency 50MSPs. And I need fourier coefficients from FFT . Which method do I apply?
1/N?
1/Fs?
1/sqrt(N)?
Which one?

댓글을 달려면 로그인하십시오.

Frantz Bouchereau
Frantz Bouchereau 2021년 7월 29일

1 개 추천

There are various ways in which you can compute and plot true power spectrum or power spectral density in MATLAB (when I say 'true power spectrum' I mean that the output values correspond to actual power values).
1) If you want to compute the power spectrum without having to specify many parameters and want the function to choose the best parameters for you, you can use pspectrum. Calling the function without outputs will give you a plot with the computed power spectrum.
2) If you want to compute power spectrum or power spectral density and want full control over the window size, window overlap, window type, and number of FFT points, you can use the Welch periodogram pwelch function. Calling the function without outputs will give you a plot with the computed power spectrum.
3) If you want to just visualize the power spectrum, you can use the Signal Analyzer app. The app let's you visualize your signals simultaneously in the time, frequency, and time-frequency domains. You can zoom into signal regions of interest and analyze the spectra at those zoomed regions.
4) If you have split your signals into multiple signal frames you can use the Spectrum Analyzer scope.
Finally, here is a popular MATLAB doc page that explains the relationship between FFT and true power spectra: Power Spectral Density Estimates Using FFT.
Brince Babu
Brince Babu 2020년 11월 13일

0 개 추천

I need to sample a analog real time signal first like a sin wave and then how to do fft in real time such that I can get the magnitude and phase angle of each of the sample

카테고리

제품

태그

질문:

2014년 11월 15일

답변:

2021년 7월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by