By Fourier theory, any waveform can be represented by a summation of a (possibly infinite) number of sinusoids, each with a particular amplitude and phase. Such a representation is referred to as the signal's spectrum (or it's frequency-domain representation). It is often easier to analyze signals and signal networks in terms of their spectral representations. As well, there are many instances where it is easier to synthesize a signal using a frequency-domain approach.
It is often the case that the spectrum of a signal can indicate aspects of the signal that would otherwise not be obvious by looking only at its time-domain representation.
For example, from the time-domain plot below it is clear that the signal is periodic, with a period of about 0.02 seconds. However, few other features of the signal are immediately clear.
Figure 1:
A complex time-domain signal.
The plot below shows the magnitude spectrum of the signal from Fig. 1. It is now obvious that the signal is comprised of only 5 frequency components, the magnitude of which is inversely proportional to frequency. As implied by the time-domain periodicity, the spectral components are harmonically aligned. From further analysis, we see the 5 components fall only at odd integer multiples of the fundamental frequency.
Figure 2:
The magnitude spectrum of the complex time-domain signal plotted above.
Frequency-domain representations are also very useful in evaluating digital filters.
As an example, a simple digital filter has a time-domain representation of the form
y[n] = x[n] + x[n-1]. It is certainly possible to gain intuition on the behavior of this filter by considering its output given various input signals in time. However, a relatively easy sequence of steps allows us to realize the filter response for all sinusoidal frequency inputs from 0 - fs / 2 as plotted below.
Figure 3:
The magnitude frequency response of the filter
y[n] = x[n] + x[n-1].
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 x[n] onto a set of k 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 x[n] consists of N samples, X[k] will consist of k=N 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 given coefficient is given by a + jb, 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 a + jb, 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. 2 was obtained by transforming an exact integer number of periods of the signal in Fig. 1. If we chose an arbitrary piece of the signal to transform, we would end up with a spectrum such as that shown below.
Figure 4:
The magnitude spectrum of the complex time-domain signal plotted in Fig. 1 using arbitrary signal length.
A brute force calculation of a length N DFT requires a number of operations roughly proportional to N2. Thus, a 1024-point DFT would require about a million multiplications and about a million additions.
Luckily, the DFT algorithm can be simplified to a form in which the required number of calculations is proportional to . Now, our 1024-point DFT can be calculated with only about 10,000 operations!
This simplified algorithm is referred to as the Fast Fourier Transform or FFT.