Beruflich Dokumente
Kultur Dokumente
Learn MATLAB
today!
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);
fft
MATLAB
Link
Answer by Matt on 15 Nov 2014
Edited by Matt on 17 Nov 2014
Accepted answer
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.
http://www.mathworks.com/help/matlab/ref/fft.html
*Edited for clarity, - see Matt J's comment for the original
statement.
Mary Jon on 16
Nov 2014
Link
Matt J on 17
Nov 2014
Link
Link
Answer by Matt J on 16 Nov 2014
Edited by 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.
Mary Jon on 16
Nov 2014
Link
Matt J on 16
Nov 2014
Link
fft(x)
ans =
1.0023e+03
>> max( abs(
fft(x(1:end-1))
ans =
1000
Mary Jon on 26
Nov 2014
Link
close
Direct link to this comment:
http://www.mathworks.com/matlabcentral
/answers/162846#comment_249975