snmeciut
Member level 4
Dear
I found a simple code for fft in below address
**broken link removed**
and converted in MATLAB code.(this is easy because matlab is as same as c code, but indeces start from 1 in matlab)
but my matlab function is not same as fft matlab fuction.
function X=DFT(x,N);
S=size(x);
X=[x,zeros(1,N-S(2))];
bit=log(N)/log(2);
N2=N/2;
k=0;
for n=0:N-2
if(n<k)
temp=X(k+1);
X(k+1)=X(n+1);
X(n+1)=temp;
end
m=N2;
while(m<=k)
k=k-m;
m=m/2;
end
k=k+m;
end
l2=1;
w=-1+0*i;
for loop=1:bit
l1=l2;
l2=l2*2;
u=1;
for n=0:l1-1
k=n;
while(k<N)
i1=k+l1+1;
temp=u*X(i1);
X(k+1)=X(k+1)+temp;
X(i1)=X(k+1)-temp;
k=k+l2;
end
u=u*w;
end
w=sqrt((1+real(w))/2)-sqrt((1-real(w))/2)*i;
end
Would you please help me to overcome this problem or send me a fft matlab code?
Best Rigards.
I found a simple code for fft in below address
**broken link removed**
and converted in MATLAB code.(this is easy because matlab is as same as c code, but indeces start from 1 in matlab)
but my matlab function is not same as fft matlab fuction.
function X=DFT(x,N);
S=size(x);
X=[x,zeros(1,N-S(2))];
bit=log(N)/log(2);
N2=N/2;
k=0;
for n=0:N-2
if(n<k)
temp=X(k+1);
X(k+1)=X(n+1);
X(n+1)=temp;
end
m=N2;
while(m<=k)
k=k-m;
m=m/2;
end
k=k+m;
end
l2=1;
w=-1+0*i;
for loop=1:bit
l1=l2;
l2=l2*2;
u=1;
for n=0:l1-1
k=n;
while(k<N)
i1=k+l1+1;
temp=u*X(i1);
X(k+1)=X(k+1)+temp;
X(i1)=X(k+1)-temp;
k=k+l2;
end
u=u*w;
end
w=sqrt((1+real(w))/2)-sqrt((1-real(w))/2)*i;
end
Would you please help me to overcome this problem or send me a fft matlab code?
Best Rigards.