Understanding the FFT: Basic Question (MATLAB)

  • Thread starter Thread starter O.J.
  • Start date Start date
  • Tags Tags
    Fft Matlab
Click For Summary

Discussion Overview

The discussion revolves around the Fast Fourier Transform (FFT) and its relationship to the Discrete Fourier Transform (DFT), particularly in the context of MATLAB implementation. Participants explore concepts such as periodicity, sampling, and the effects of input signal length on FFT results.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants assert that the FFT is a fast implementation of the DFT and that both are periodic in time and frequency.
  • There is a claim that a cosine input to the FFT, when sampled above the Nyquist rate, should yield two impulses in the frequency domain.
  • One participant points out that the MATLAB code in the referenced document defines a sine wave with 100 samples per period but creates an array with 101 samples, which may lead to unexpected FFT results.
  • Another participant suggests that using an FFT with a length greater than the time domain signal length raises questions about the mathematical implications.
  • There is a request for clarification on the role of windowing and whether using an FFT with a length greater than the signal length is effectively a form of windowing.
  • One participant questions whether the FFT process involves padding the input with trailing zeros, while another clarifies that the specific code discussed does not involve padding but rather has ones at both ends of the array.

Areas of Agreement / Disagreement

Participants express differing views on the implications of input length and periodicity in FFT results. There is no consensus on the correct interpretation of the MATLAB code or the effects of padding versus periodicity.

Contextual Notes

Participants note that real-world data may not align perfectly with theoretical expectations, and the discussion includes references to practical applications such as windowing functions to improve FFT results.

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.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 9 ·
Replies
9
Views
4K
Replies
3
Views
5K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K