The DFT determines sinusoidal “weights” via the inner product of sinusoids and the signal.
The DFT can be interpreted as the sum of projections of onto a set of sampled complex sinusoids or sinusoidal basis functions at (normalized) radian frequencies given by
.
In this way, the DFT and its inverse provide a “recipe” for reconstructing a given discrete-time signal in terms of sampled complex sinusoids.
If the signal consists of samples, will consist of frequency weights (assuming no zero-padding). Based on the sampling theorem, however, only the first half of these frequency components are unique.
The DFT coefficients are complex values. To plot the magnitude response of a signal's spectrum, we calculate the magnitude of each coefficient. For example, if a coefficient is equal to , its magnitude can be determined as
. The Matlab function abs performs this calculation.
The phase response of a signal is given by the “angles” of its complex DFT coefficients. For a coefficient given by , the phase angle is determined as
. The Matlab function angle performs this calculation.
In general, the spectra of real-world signals will not look as “clean” as the figures above. In fact, the spectrum of Fig. 3 was obtained by transforming an exact integer number of periods of the signal in Fig. 2. If we chose an arbitrary piece of the signal to transform, we would more likely end up with a spectrum such as that shown below.
Figure 5:
The magnitude spectrum of the time-domain signal plotted in Fig. 2 using an arbitrary DFT length.