If more than NN equally spaced frequency samples of
a length-NN signal are desired, they can easily be obtained
by zero-padding the discrete-time signal and computing a DFT of the
longer length.
In particular, if
LN
LN
DTFT samples are desired
of a length-NN sequence, one can compute the length-
LN
LN
DFT of a
length-
LN
LN zero-padded
sequence
zn={xn if 0≤n≤N−10 if N≤n≤LN−1
z
n
x
n
0
n
N
1
0
N
n
L
N
1
X
w
k
=2πkLN=∑
n
=0N−1xne−(i2πknLN)=∑
n
=0LN−1zne−(i2πknLN)=
DFT
L
N
zn
X
w
k
2
k
L
N
n
N
1
0
x
n
2
k
n
L
N
n
L
N
1
0
z
n
2
k
n
L
N
DFT
L
N
z
n
Note that
zero-padding interpolates the spectrum. One
should always zero-pad (by about at least a factor of 4) when
using the DFT to approximate
the DTFT to get a clear
picture of the DTFT.
While performing computations on zeros may at first seem inefficient,
using FFT algorithms, which generally
expect the same number of input and output samples, actually makes this
approach very efficient.
Figure 1 shows the magnitude of the DFT values corresponding to the
non-negative frequencies of a real-valued length-64 DFT of a length-64 signal,
both in a "stem" format to emphasize the discrete nature of the DFT frequency samples,
and as a line plot to emphasize its use as an approximation to the
continuous-in-frequency DTFT.
From this figure, it appears that the signal has a single dominant
frequency component.
Zero-padding by a factor of two by appending 64 zero values to the
signal and computing a length-128 DFT yields
Figure 2.
It can now be seen that the signal consists of at least two narrowband
frequency components; the gap between them fell between DFT samples
in
Figure 1, resulting in a misleading picture of the
signal's spectral content.
This is sometimes called the
picket-fence effect, and
is a result of insufficient sampling in frequency.
While zero-padding by a factor of two has revealed more structure,
it is unclear whether the peak magnitudes are reliably rendered, and
the jagged linear interpolation in the line graph does not yet reflect
the smooth, continuously-differentiable spectrum of the DTFT
of a finite-length truncated signal.
Errors in the apparent peak magnitude due to insufficient frequency sampling
is sometimes referred to as
scalloping loss.
Zero-padding to four times the length of the signal,
as shown in
Figure 3,
clearly shows the spectral structure and reveals that the magnitude of
the two spectral lines are nearly identical.
The line graph is still a bit rough and the peak magnitudes and frequencies
may not be precisely captured, but the spectral characteristics of the
truncated signal are now clear.
Zero-padding to a length of 1024, as shown in
Figure 4
yields a spectrum that is smooth and continuous to the resolution of the
computer screen, and produces a very accurate rendition of the DTFT of
the
truncated signal.
The signal used in this example actually consisted of two pure sinusoids of
equal magnitude.
The slight difference in magnitude of the two dominant peaks, the breadth
of the peaks, and the sinc-like lesser
side lobe peaks throughout frequency are artifacts of the
truncation, or windowing, process used to practically approximate the DFT.
These problems and partial solutions to them are discussed in the following section.