MATLAB: Simple fft code problem

fftMATLAB

x=rand(1,8);
for k=1:8
for m=1:8
l(m)=x(m)*exp(-i*2*pi*k*m/8);
end
X(k)=sum(l);
end
X=X
I used this code to implement the fast Fourier transform but it didn't work. Is there any help?

Best Answer

%k and m start at 0
x=rand(1,8);
for k=0:7
for m=0:7
l(m+1)=x(m+1)*exp(-i*k*m*pi/4);
end
X(k+1)=sum(l);
end
%or
R=exp(-i*2*pi/8)
k=0:7;
XX=exp(-i*pi/4).^(k'*k)*x'
Remark: for big array, you must use FFT algorithm