FFT not matching with Continuous FT
조회 수: 12 (최근 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..
댓글 수: 0
채택된 답변
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
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
댓글 수: 0
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:
댓글 수: 0
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
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!