The spacing of the samples in the frequency domain has been shown to be related to the sampling rate and number of samples in equation 15. If we wished to reduce the frequency spacing, , then there are two options for doing so. The first is to increase the sample spacing by decreasing the sampling rate fs. However this would move the periodic repetitions in frequency closer together. Alternatively the number of samples, N, can be increased to reduce the frequency domain sample spacing. However, if only the 64 samples shown are available, how can additional samples be introduced. One method is to simply append 0 values to the end of the data set, hence increasing the total number of samples. This is termed zero padding. To see the effect of this click on the checkbox in the demonstration.
Each frame of the animation shows the result of doubling the total number of samples N by adding zeros to the end of the original data sequence. It is clear that every doubling of N results in a halving of . It should now be clear for the two signals that we have already looked at that the DFT is strongly related to a sampled version of the Fourier transform as mentioned previously. To understand the shape refer back to section 1.4
You may ask why bother with zero padding. One answer is that it allows you to ascertain frequencies with more accuracy. Switch the input signal to a 333Hz sine wave. With the zero padding on you can, by zooming into the frequency domain plot, see that the peak of the two highest ``lobes'' lie at approximately -333Hz and 333Hz as expected. (Actually at this frequency spacing the highest pulses are at 336Hz and -336Hz). Now try this after switching zero padding off. You will find that the best estimate that can be made is that the frequency is around 375Hz. We will also find zero padding useful in explaining what happens with windowing.
It is also noticable in the non-zero padded version that not only are there non-zero values at 375Hz and 7625Hz (being the closest values to 333Hz and 7667Hz that are represented in the DFT), all of the other samples are non-zero. Compare this with the Fourier transform of a 333Hz cosine wave and you should see that it has been sampled not at the zero amplitude values of the frequency domain as the 500Hz sine wave was, but at non-zero amplitudes for all the samples spaced by 125Hz. This effect in the DFT is called leakage as the power of the sine wave ``leaks'' into other frequency bins. (A bin is simply a sample in the frequency domain, eg 375Hz is the fourth bin in the non-zero padded spectrum, and the 64th bin in the zero padded version).
You may wish to investigate at this stage what the zero padded versions of the other signals look like.