Understanding the FFT: Basic Question (MATLAB)

  • Thread starter Thread starter O.J.
  • Start date Start date
  • Tags Tags
    Fft Matlab
AI Thread Summary
The discussion centers on the relationship between the Fast Fourier Transform (FFT) and the Discrete Fourier Transform (DFT), emphasizing that the FFT is a rapid implementation of the DFT, which is periodic in both time and frequency. A key point raised is that when a cosine input is sampled above the Nyquist rate, the expectation is to see two impulses in the frequency spectrum; however, discrepancies arise due to the input array's length and structure. It is clarified that using 101 samples instead of 100 creates a periodic extension of the signal, leading to unexpected results in the FFT output. The conversation also touches on the importance of windowing functions in practical applications to clean up FFT results, as well as the implications of using an FFT length greater than the signal length. Overall, understanding the nuances of input data structure and windowing is crucial for accurate FFT analysis.
O.J.
Messages
198
Reaction score
0
Hello,

I have a very basic FFT question. Correct me if I am wrong, but the FFT is a fast implementation of the DFT (which is essentially the same as Discrete Time Fourier series). The DFT is periodic in time and frequency. Thus if you input a time domain made of 4 times samples for example to the FFT block, it will give u a frequency spectrum 4 point output. Both these, the input and output are considered periodic. Also, doesn't the FFT treat its input as periodic?
Shouldnt a cosine input to our FFT block (as long as its sampled above the nyquist) always give us two impulses (since its periodic)? Why can't we get those two impulses?

and if so, then why does this document (and my experiemental results) contradict this:
Read page 15.
http://www.ee.nmt.edu/~elosery/matlab/matlab.pdf
 
Physics news on Phys.org
O.J. said:
Hello,

I have a very basic FFT question. Correct me if I am wrong, but the FFT is a fast implementation of the DFT (which is essentially the same as Discrete Time Fourier series). The DFT is periodic in time and frequency. Thus if you input a time domain made of 4 times samples for example to the FFT block, it will give u a frequency spectrum 4 point output. Both these, the input and output are considered periodic. Also, doesn't the FFT treat its input as periodic?
Shouldnt a cosine input to our FFT block (as long as its sampled above the nyquist) always give us two impulses (since its periodic)?

That is correct.

Why can't we get those two impulses?

and if so, then why does this document (and my experiemental results) contradict this:
Read page 15.
http://www.ee.nmt.edu/~elosery/matlab/matlab.pdf

Start at section 7.3 on page 13. The problem is that the code defines a sine wave with 100 samples per period, but it creates an array with 101 samples.

That looks nice plotted in the time domain (Fig 9), because the X axis goes from 0 to 1 exactly.

The FFT of 101 data points is doing the FFT of the periodic time series

1, [99 points defining the cosine wave], 1, 1, [99 points repeated], 1, 1, etc

But the correct time series to represent the cosine wave is

1 [99 points], 1, [99 points], 1, etc

If you do the FFT with 100 points you should get what you expected, i.e. all the FFT coefficients except two will be 0 (to within rounding error).

Note, for "real world" measured data, the signal frequencies will not usually be exact multiples of the sample length. The practical way to clean up the FFT is to use a windowing function on the data - but I think your reference is meant to be a cheat sheet on using Matlab, not a course on practical DSP.
 
Thanks alpha zero. That cleared up many things. Can you tell me what it mathematically means to use an FFT with a length more than the time domain signal length?
 
Also, can you elaborate more on the role of windowing? Does having an FFT with N greater than signal length count as effectively windowing?
 
This tutorial might be useful as an introduction to the concepts - plenty of graphs, but not much math.

http://www.bores.com/courses/intro/freq/index.htm

Any textbook on DSP will have the math, if you need that as well, but if you are using Matlab then understanding how the pieces of the jigsaw fit together is arguably just as important as knowing the mathematical details of each individual piece.
 
Also another question. You said: "The FFT of 101 data points is doing the FFT of the periodic time series

1, [99 points defining the cosine wave], 1, 1, [99 points repeated], 1, 1, etc"

But doesn't taking a larger point FFT mean padding the input with trailing zeros? Your input seems padded with 1's. Am I right?
 
O.J. said:
Also another question. You said: "The FFT of 101 data points is doing the FFT of the periodic time series

1, [99 points defining the cosine wave], 1, 1, [99 points repeated], 1, 1, etc"

But doesn't taking a larger point FFT mean padding the input with trailing zeros? Your input seems padded with 1's. Am I right?

I was talking about the first lines of code in section 7.3 on page 13 of the PDF, which defines an array of length 101, and creates 101 data values with a 1 at both ends. Then it does the fft using 101 points. Up to that point, there isn't any padding.

(Disclaimer - I haven't actually run the code in Matlab, but that's what I think it does).

You are right that if an array is padded, then it is padded with zeros.
 
Back
Top