Discrete Foureir Transformation

One and Two dimensional Discrete Fourier Transform without built in Fourer Transformation functions
186 Downloads
Updated 28 May 2016

View License

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
Montadar

Cite As

Montadar Abas Taher (2024). 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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0

I have removed some comments