dfft#

Purpose#

Computes a discrete Fourier transform.

Format#

y = dfft(x)#
Parameters:

x (Nx1 vector) – Values used to compute the discrete Fourier transform.

Returns:

y (Nx1 vector) – The discrete Fourier transform.

Examples#

In this example we will a use a discrete sample of frequencies given by

\[f[k] = 5 + 2 * cos(\frac{\pi}{2}k - \frac{\pi}{2}) + 3cos(\pi k)\]
// Set k
k = seqa(0, 1, 4);

// Compute discrete frequencies
f_k = 5 + 2 * cos(pi/2*k - 90*pi/180) + 3 * cos(pi*k);

After this f_k is equal to:

8
4
8
0

Now take the discrete Fourier transform of f_k:

// Discrete Fourier transform
print dfft(f_k);

After the code the discrete Fourier transform is printed:

5
0 - 1i
3 + 0i
0 + 1i

Remarks#

The transform is divided by \(N\).

This uses a second-order Goertzel algorithm. It is considerably slower than fft(), but it may have some advantages in some circumstances. For one thing, \(N\) does not have to be an even power of 2.

Source#

dfft.src

See also

dffti(), fft(), ffti()