0
$\begingroup$

For a given signal, I've been told that you can pad the vector with $0$s at the end to get a larger DFT, and as a result get more precision in frequency bins.

  • What are the limits to this approach?
  • Is there a loss of accuracy when you do this?
  • Or if not, why wouldn't you just use a small number of points and pad with zeros all the time?
$\endgroup$
2

2 Answers 2

2
$\begingroup$

Be careful with this in thinking that you would increase your frequency resolution- you won't! Zero padding is very effective in iterpolating more samples between the samples you have, but it does not add any more information about the frequency content of your signal between your original bins. You do not lose anything either.

The frequency resolution in all cases is $1/T$ where T is the time length of your data.

Please see my answer at this post specifically for more details on zero-padding and how it works: What happens when N increases in N-point DFT

$\endgroup$
5
  • $\begingroup$ Thanks for the response, your other post makes sense. Is that 1/T resolution actually based on a signal length requirement, or is it just due to the structure of the DFT? Meaning, in a DFT matrix, the 1st row is a DC signal, the 2nd row is a single sinusoid, the 3rd is 2 periods, etc. But if I were to, say, double the exponential of each term in that DFT matrix(so, DC, 2 periods, 4, 6, etc), would that allow me to see higher resolution frequencies, because I'm multiplying by higher sinusoids, or would I just be interpolating in that instance as well? $\endgroup$
    – Zephyr
    Commented Mar 1, 2017 at 2:36
  • $\begingroup$ No each of those frequencies has a "bandpass" filter around it with a BW of 1/T (effectively). This is a fundamental relationship between time and frequency resolution. Another way to possibly see this is take the FT of a pulse with length T, it is a Sinc in frequency with nulls at 1/T. $\endgroup$ Commented Mar 1, 2017 at 3:13
  • $\begingroup$ @Zephyr see my response here dsp.stackexchange.com/questions/37925/… on how the DFT can be viewed as a "bank of filters" which really helps to see how the frequency resolution is effected by the length of the DFT, which is the length T I mention since we have the same number of points in the time domain as in the frequency domain. So also see from the link I gave above that when you zero pad, the filter shape of each "bank" is traced out (due to the interp. the zero padding provides), but BW is unchanged $\endgroup$ Commented Mar 1, 2017 at 11:55
  • $\begingroup$ Thanks, the filter explanation makes it more clear. I'm just trying to get a more intuitive understanding of this idea. So would it be fair to say, as a different framing of the concept, that in order to discern a frequency component you need to sample over a time range(N/Fs) such that 1 full wavelength of the desired frequency component fits in the window? As in, if you want to discern resolution of 5 Hz, then you need a window covering 0.2 seconds? So if your sampling frequency is 100 Hz, and you have 10 samples, you can't see a frequency component with a period over 0.1 s? $\endgroup$
    – Zephyr
    Commented Mar 1, 2017 at 13:17
  • $\begingroup$ Yes exactly, and if you want to actually be able to discern between the frequencies you would need to be longer than 1/T (see my example showing that). $\endgroup$ Commented Mar 1, 2017 at 13:19
0
$\begingroup$

"why wouldn't you just use a small number of points and pad with zeros all the time"

The thing you have to remember is that with the DFT what you are doing is sampling the continuous discrete spectrum of your signal, which is the real thing that you want to observe and analyse. So lets say you have some signal, and you take only 4 samples, and then zero pad it with 1020 zeros, and do a DFT of 1024. Effectively what you are doing is taking your discrete time signal, applying a square window of size 4 (leaving only 4 samples), which will result in your spectrum being "smeared out" due to the operation of the convolution in the frequency domain with the transform of your size 4 square window, and then with the DFT sampling that spectrum to a very good resolution. So you get a lot of detail, to observe a spectrum which has been ruined in the first place by taking to few samples.

In fact, if you are going to implement the DFT in hardware using the FFT algorithm, zero padding is almost never done. The only reason you would zero pad is if you have to plot the spectrum and you want many points so it looks smooth. But in real time processing, since you don't actually gain any information by doing it, you would just do a DFT of the number of time samples that you have.

Always remember, if you have a discrete time signal, the "Real spectrum" is obtained with the Discrete time Fourier Transform, which is a continuous function of $\omega$. The DFT is a computational tool for calculating it with a computer.

$\endgroup$
3
  • $\begingroup$ Perhaps "almost never done" is too strong of a statement? Consider the following applications for zero padding-- radix-2 algorithms are more efficient so zero padding out to the next power of 2 (or power of 4 in some cases for radix 4) or more significantly avoiding any large prime factors can improve real time performance. Also when using the FFT for analysis zero padding is often done to compute samples of the DTFT, such as determining the frequency response of a FIR: compare fft([1 1 1 1]) to fft([1 1 1 1], 512) which is identical to freqz([1 1 1 1]). $\endgroup$ Commented Mar 1, 2017 at 12:14
  • $\begingroup$ Yes you are absolutely right. Perhaps I should have expanded the explanation a bit more to say that unless there are very very good reasons for doing so, an engineeer is very likely to choose a window length that is a power of two it it will then apply FFT. And of course what you mention about the filter is true, but You will not put that output into an algorithm, it is merely to watch it with your eyes and so it looks nice. That was my point. $\endgroup$
    – bone
    Commented Mar 1, 2017 at 12:51
  • $\begingroup$ Yes your point was very good- I think if you clarify that it is specific to implementation on hardware (processors, dsp, fpga etc) then you will be spot on (and the block size as you point out would be chosen to be a power of 2 initially most likely). The FFT is used for computational analysis as well and in that case it is much more than something to watch with your eyes (an efficient way to compute the frequency response of a FIR at many frequencies that are not be on bin center is a perfect example, and this isn't just for visual purposes). $\endgroup$ Commented Mar 1, 2017 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.