Created
March 26, 2015 08:00
-
-
Save rflamary/7cedc5658b2ae9367d4a to your computer and use it in GitHub Desktop.
discrete fourier transform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [Xk] = dft(xn,N) | |
| % Computes Discrete Fourier Transform | |
| % ----------------------------------- | |
| % [Xk] = dft(xn,N) | |
| % Xk = DFT coeff. array over 0 <= k <= N-1 | |
| % xn = N-point finite-duration sequence | |
| % N = Length of DFT | |
| % | |
| n = [0:1:N-1]; % row vector for n | |
| k = [0:1:N-1]; % row vecor for k | |
| WN = exp(-j*2*pi/N); % Wn factor | |
| nk = n'*k; % creates a N by N matrix of nk values | |
| WNnk = WN .^ nk; % DFT matrix | |
| Xk = xn * WNnk; % row vector for DFT coefficients |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment