This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Discrete Fourier Transform (DFT)


Spectral analysis is the process of identifying component frequencies in data. For discrete data, the computational basis of spectral analysis is the discrete Fourier transform (DFT). The DFT transforms time- or space-based data into frequency-based data.

The DFT of a vector x of length n is another vector y of length n:


where ω is a complex nth root of unity:


This notation uses i for the imaginary unit, and p and j for indices that run from 0 to n–1. The indices p+1 and j+1 run from 1 to n, corresponding to ranges associated with MATLAB® vectors.

Data in the vector x are assumed to be separated by a constant interval in time or space, dt = 1/fs or ds = 1/fs, where fs is the sampling frequency. The DFT y is complex-valued. The absolute value of y at index p+1 measures the amount of the frequency f = p(fs / n) present in the data.

The first element of y, corresponding to zero frequency, is the sum of the data in x. This DC component is often removed from y so that it does not obscure the positive frequency content of the data.

Visualizing the DFT

The documentation example function fftgui opens a graphical user interface that allows you to explore the real and imaginary parts of a data vector and its DFT. (Here fft refers to efficient computation of the DFT by the MATLAB fft function, as discussed in Fast Fourier Transform (FFT).)

Add the examples folder to your path for access to the function fftgui.


If x is a vector,


plots the real and imaginary parts of both x and its DFT (fft(x)). Use your mouse to drag points in any of the plots and the points in the other plots respond to the changes.

For example, use fftgui to display the DFT of a unit impulse at x(1):

x = [1 zeros(1,11)];

The transform is quite different if the unit impulse is at x(2):

x = [0 1 zeros(1,10)];

The following commands display DFTs of square and sine waves, respectively:

x = [ones(1,25),-ones(1,25)];

t = linspace(0,1,50);
x = sin(2*pi*t);

The midpoint of the DFT (or the point just to the right of the midpoint if the length is even), corresponding to half the sampling frequency of the data, is the Nyquist point. For real x, the real part of the DFT is symmetric about the Nyquist point, and the imaginary part is antisymmetric about the Nyquist point.

Was this topic helpful?