Signal Processing Toolbox |
The discrete Fourier transform, or DFT, is the primary tool of digital signal processing. The foundation of the Signal Processing Toolbox is the fast Fourier transform (FFT), a method for computing the DFT with reduced execution time. Many of the toolbox functions (including z-domain frequency response, spectrum and cepstrum analysis, and some filter design and implementation functions) incorporate the FFT.
MATLAB provides the functions fft
and ifft
to compute the discrete Fourier transform and its inverse, respectively. For the input sequence x and its transformed version X (the discrete-time Fourier transform at equally spaced frequencies around the unit circle), the two functions implement the relationships
In these equations, the series subscripts begin with 1 instead of 0 because of the MATLAB vector indexing scheme, and
Note
MATLAB uses a negative j for the fft function. This is an engineering convention; physics and pure mathematics typically use a positive j.
|
fft
, with a single input argument x
, computes the DFT of the input vector or matrix. If x
is a vector, fft
computes the DFT of the vector; if x
is a rectangular array, fft
computes the DFT of each array column.
For example, create a time vector and signal:
The DFT of the signal, and the magnitude and phase of the transformed sequence, are then
To plot the magnitude and phase, type the following commands:
f = (0:length(y)-1)*
99/length(y); % Frequency vector plot(f,m); title('Magnitude'); set(gca,'XTick',[15 40 60 85]); figure; plot(f,p*
180/pi); title('Phase'); set(gca,'XTick',[15 40 60 85]);
A second argument to fft
specifies a number of points n
for the transform, representing DFT length:
In this case, fft
pads the input sequence with zeros if it is shorter than n
, or truncates the sequence if it is longer than n
. If n
is not specified, it defaults to the length of the input sequence. Execution time for fft
depends on the length, n
, of the DFT it performs; see the fft
reference page in the MATLAB documentation for details about the algorithm.
The inverse discrete Fourier transform function ifft
also accepts an input sequence and, optionally, the number of desired points for the transform. Try the example below; the original sequence x
and the reconstructed sequence are identical (within rounding error).
This toolbox also includes functions for the two-dimensional FFT and its inverse, fft2
and ifft2
. These functions are useful for two-dimensional signal or image processing. The goertzel
function, which is another algorithm to compute the DFT, also is included in the toolbox. This function is efficient for computing the DFT of a portion of a long signal.
It is sometimes convenient to rearrange the output of the fft
or fft2
function so the zero frequency component is at the center of the sequence. The MATLAB function fftshift
moves the zero frequency component to the center of a vector or matrix.
Linear System Transformations | Selected Bibliography |
© 1994-2005 The MathWorks, Inc.