Here is my code for the 2D Discrete Fourier transform. I know, it is a bit brute force-ish, but I did not have much programming experience before taking Mathematical Physics this semester.
I am wondering why my program is so slow, and if there are any things that jump out that would make it more robust [it takes so long, and I am hoping that someone more experienced than I can see something wrong].
function [trans] = d2ftrans(Matrix)
[o,p] = size(Matrix);
F = 0;
for v = 0:1:p-1
for u = 0:1:o-1
for Xi = 0:1:o-1
for Yi = 0:1:p-1
S = Xi+1;
T = Yi+1;
c = Matrix(S,T) * exp(-1i*2*pi*(u*Xi/o + v*Yi/p));
F = F+c;
end
end
Si = v+1;
Ti = u+1;
G(Ti,Si) = F;
F = 0;
end
end
trans = G;