FFT not matching with Continuous FT

14 次查看(过去 30 天)
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..

采纳的回答

Rick Rosson
Rick Rosson 2011-8-4
Again, using dx as the scale factor is perfectly valid and correct. The results you are seeing in practice do in fact match the theory. Remember, the theory says you should see an impulse of size 1/2 at +Fc and -Fc. What is the height of an impulse of size 1/2? It is not 1/2. The height of an impulse is infinite. The area of the impulse is 1/2, not the height of the impulse.
What you are seeing is two discrete impulses of height 5. What is the width of those impulses? I would argue that the width (the frequency increment or distance between each of the discrete frequencies) of each impulse is 0.1 hertz, so that the area of the impulses is 1/2, as expected.
Does that make sense?

更多回答(5 个)

Rick Rosson
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

Stuart
Stuart 2011-8-4

Seth Popinchalk
Seth Popinchalk 2011-8-4
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
Rick Rosson 2011-8-4
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
  1 个评论
Stuart
Stuart 2011-8-4
Sure, but I need a particular scale factor, and the theory of what that scale factor should be (ie T) is not aligning with what I am getting in practice.

请先登录,再进行评论。


Rick Rosson
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

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by