Zero Padding in the Time Domain
Unlike time-domain interpolation , ideal spectral interpolation is very easy to implement in practice by means of zero padding in the time domain. That is,
Since the frequency axis (the unit circle in the plane) is finite in length, ideal interpolation can be implemented exactly to within numerical round-off error. This is quite different from ideal (band-limited) time-domain interpolation, in which the interpolation kernel is sinc ; the sinc function extends to plus and minus infinity in time, so it can never be implemented exactly in practice.3.9
To interpolate a uniformly sampled spectrum , by the factor , we may take the length inverse DFT, append zeros to the time-domain data, and take a length DFT. If is a power of two, then so is and we can use a Cooley-Tukey FFT for both steps (which is very fast):
This operation creates new bins between each pair of original bins in , thus increasing the number of spectral samples around the unit circle from to . An example for is shown in Fig.2.4 (compare to Fig.2.3).
X = fft(x,N); % FFT size N > length(x)
Another reason we zero-pad is to be able to use a Cooley-Tukey FFT with any window length . When is not a power of , we append enough zeros to make the FFT size be a power of . In Matlab and Octave, the function nextpow2 returns the next higher power of 2 greater than or equal to its argument:
N = 2^nextpow2(M); % smallest M-compatible FFT size
Suppose we perform spectrum analysis on some sinusoid using a length window. Without zero padding, the DFT length is . We may regard the DFT as a critically sampled DTFT (sampled in frequency). Since the bin separation in a length- DFT is , and the zero-crossing interval for Blackman-Harris side lobes is , we see that there is one bin per side lobe in the sampled window transform. These spectral samples are illustrated for a Hamming window transform in Fig.2.3b. Since in Table 5.2, the main lobe is 4 samples wide when critically sampled. The side lobes are one sample wide, and the samples happen to hit near some of the side-lobe zero-crossings, which could be misleading to the untrained eye if only the samples were shown. (Note that the plot is clipped at -60 dB.)
If we now zero pad the Hamming-window by a factor of 2 (append 21 zeros to the length window and take an point DFT), we obtain the result shown in Fig.2.4. In this case, the main lobe is 8 samples wide, and there are two samples per side lobe. This is significantly better for display even though there is no new information in the spectrum relative to Fig.188.8.131.52
Incidentally, the solid lines in Fig.2.3b and 2.4b indicating the ``true'' DTFT were computed using a zero-padding factor of , and they were virtually indistinguishable visually from . ( is not enough.)
The examples in Fig.2.5 show how zero-padding helps in clarifying the true peak of the sampled window transform. With enough zero-padding, even very simple interpolation methods, such as quadratic polynomial interpolation, will give accurate peak estimates.
Zero-Phase Zero Padding
Interpolating a DFT