FFT not matching with Continuous FT
显示 更早的评论
The fourier transform of a unit amplitude cosine with period T is two delta functions, at -1/T and +1/T with amplitude 1/2.
dx = .1;
x = 0:dx:9.9;
fs = 1/dx;
y = cos(x*2*pi/10);
Y = dx*fft(y); %Continous FT and DFT differ by scale dx
X = -fs/2 : fs/length(x) : fs/2 - fs/length(x)
Y = fftshift(Y);
plot(X,real(Y));
The amplitudes of my deltas is 5 and not .5. Why? I've scaled by the appropriate constant..
采纳的回答
更多回答(5 个)
Rick Rosson
2011-8-4
You have scaled by the appropriate constant for the Continuous Time Fourier Transform (CTFT), but the fft function computes the Discrete Fourier Transform (DFT). The appropriate scaling factor for the DFT is the number of samples N, not the time increment dx.
Please try:
N = size(y,2);
Y = fftshift(fft(y))/N;
HTH.
Rick
Seth Popinchalk
2011-8-4
0 个投票
Computing the correct scaling of the FFT is difficult as you must also account for the length of the signal data.
This is explained in more detail in this great blog post from a couple years ago:
Rick Rosson
2011-8-4
0 个投票
Technically speaking, it is not a question of whether one scale factor is "correct" and the other "incorrect". The issue is really that both scaling factors are correct, but they are providing two different ways of looking at the same result. In effect, each of two scaling factors provides in the same exact Fourier spectrum, but in different units of measure. It is really a question of what you want to see and for what purpose. The choice of scaling factor is just that: a choice. You need to choose the right scaling factor for the right reason.
BTW, these two scaling factors are not the only ones. You can also choose not to scale the result at all, or you can convert the spectrum from an linear scale to a logarithmic scale (in the form of decibels). And there are still others as well.
Ultimately, the scaling factor of the spectrum is really quite unimportant for most applications. In general, it is the overall shape of the spectrum that matters, not the absolute scale.
HTH.
Rick
Rick Rosson
2011-8-4
One other thing I noticed in the code you posted: When you plot the spectrum, you should plot the magnitude of the Fourier coefficients, not the real-part of the coefficients.
So, instead of
plot(X,real(Y));
please try
plot(X,abs(Y));
In this particular example, it may not make any difference, but in general, it will.
HTH.
Rick
类别
在 帮助中心 和 File Exchange 中查找有关 Discrete Fourier and Cosine Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!