Computes a discrete Fourier transform.
Parameters: x (Nx1 vector) – Values used to compute the discrete Fourier transform. Returns: y (Nx1 vector) – The discrete Fourier transform.
In this example we will a use a discrete sample of frequencies given by
// 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);
f_k is equal to:
8 4 8 0
Now take the discrete Fourier transform of
// Discrete Fourier transform print dfft(f_k);
After the code the discrete Fourier transform is printed:
5 0 - 1i 3 + 0i 0 + 1i
The transform is divided by \(N\).
This uses a second-order Goertzel algorithm. It is considerably slower
fft(), but it may have some advantages in some circumstances. For one
thing, \(N\) does not have to be an even power of 2.