# What exactly is the "n-point DFT" that fft() computes?

387 views (last 30 days)
Jonathan on 23 Sep 2014
Answered: Jonathan on 23 Sep 2014
I am trying to understand exactly how matlab is computing the fft when you call fft(myData, N), where N < length(myData).
Is it basically doing something along the lines of FFT pruning, as described by: Pruned FFTs?
In other words, it is computing the "first K outputs of an N point FFT" as detailed in the above link from fftw.org?
Thanks

Jonathan on 23 Sep 2014
I found a site where you can get intelligent answers to your questions: FFT Matlab - What is a N-point FFT?
If you are going to perform a N-point FFT in MATLAB, to get an appropriate answer, the length of your sequence should be lesser than or equal to N. Usually this N is chosen in power of 2, because MATLAB employs a Radix-2 FFT if it is, and a slower algorithm if it is not.
So, if you give a sequence of length 1000 for a 2056 point FFT, MATLAB will pad 1056 zeros after your signal and compute the FFT. Similarly, if your sequence length is 2000, it will pad 56 zeros and perform a 2056 point FFT.
But if you try to compute a 512-point FFT over a sequence of length 1000, MATLAB will take only the first 512 points and truncate the rest. If you try to compare between a 1024 point FFT and a 2056-point FFT over a [1:1000], you will get a similar plot.
So the moral: choose your N to be greater than or equal to the length of the sequence.

Youssef Khmou on 23 Sep 2014
N is the number of points used to calculate the fft, it does not increase physical resolution but adds more point to the spectrum for more visual resolution, N is arbitrary.

Jonathan on 23 Sep 2014
Yes, I know. But how is it computing this when N<length(data)?
Youssef Khmou on 23 Sep 2014
for every element of the frequency vector X(f), it is a sum of X(t)*exp(-2*pi*j*t*f) where t lies in [1 M], M is the length of the signal, and f lies in [1 N], and N is the value chosen whether N > M or N< M.

### Community Treasure Hunt

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

Start Hunting!