You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
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 (2026). Discrete Foureir Transformation (https://www.mathworks.com/matlabcentral/fileexchange/57382-discrete-foureir-transformation), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0 (607 Bytes)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0 | I have removed some comments |
|
