2d DFT using 1D DFT twice
19 views (last 30 days)
Show older comments
How can I do 2D DFT by doing the fourier transform in the X direction first and then the Y direction. Basically what fft2 does but without using fft and using for loop? I am sure I have made many fundamental mistakes.
M=100;
N=100;
X=zeros(M,N);
wm=exp((-1j.*2.*pi)./M);
wn=exp((-1j.*2.*pi)./N);
xm=sin(4*pi.*(1:M))+cos(6*pi.*(1:M));
for u=1:M
X(u)=0;
for m=1:M
X(u,:)=X(u,:)+xm(m)*wm*u*m;
end
end
for v=1:N
X(:,v)=0;
for n=1:N
X(:,v)=X(:,v)+xm(n)*wn*v*n;
end
end
plot(abs(X));
1 Comment
Matt J
on 1 Feb 2013
Your xm doesn't look 2D, so it's not clear in what way you wish to apply a 2D DFT to it.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!