## Discrete Foureir Transformation

Version 1.0 (607 Bytes) by
One and Two dimensional Discrete Fourier Transform without built in Fourer Transformation functions

Updated 28 May 2016

I tried to make the code very simple:
first create this one dimensional DFT function
%----------------------------------------------------------------
function [Xk] = dft(xn)
N=length(xn);
n = 0:1:N-1; % row vector for n
k = 0:1:N-1; % row vecor for k
WN = exp(-1j*2*pi/N); % Twiddle factor (w)
nk = n'*k; % creates a N by N matrix of nk values
WNnk = WN .^ nk; % DFT matrix
Xk = (WNnk*xn );
%----------------------------------------------------------------
now, use this function which is the second dimension:
%----------------------------------------------------------------
function out=dft2(x)
y=zeros(size(x));
y1=y;
C=size(x,2); %number of columns
for c=1:C
y(:,c)=dft(x(:,c));
end
R=size(x,1); %number of rows
for r=1:R
y1(r,:)=dft(y(r,:).');
end
out=y1;
%----------------------------------------------------------------

Note: do not forget to save them as the names of the functions as dft.m and dft2.m both in the same folder. Now make the folder your current working folder, now, you can call the one dimensional dft or the two dimensions dft

Enjoy

### Cite As

Montadar Abas Taher (2023). Discrete Foureir Transformation (https://www.mathworks.com/matlabcentral/fileexchange/57382-discrete-foureir-transformation), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2009a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Categories
Find more on Discrete Fourier and Cosine Transforms in Help Center and MATLAB Answers