FFT not matching with Continuous FT
Ältere Kommentare anzeigen
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..
Akzeptierte Antwort
Weitere Antworten (5)
Rick Rosson
am 4 Aug. 2011
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
am 4 Aug. 2011
0 Stimmen
Seth Popinchalk
am 4 Aug. 2011
0 Stimmen
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
am 4 Aug. 2011
0 Stimmen
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 Kommentar
Stuart
am 4 Aug. 2011
Rick Rosson
am 4 Aug. 2011
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
Kategorien
Mehr zu Discrete Fourier and Cosine Transforms finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!