ditfft.m
来自「基2ditfft的matlab源程序」· M 代码 · 共 41 行
M
41 行
function XK=ditfft(xn,N)
%it is a function of DIT_FFT based 2 .
%the argument 'xn'is the sample sequence input.
%the argument 'N'is the length of the sample sequence input.
%------------------add zeros----------------------------%
if length(xn)<N
xn=[xn,zeros(1,N-length(xn))];
end
%--------------bit reversal(Rader Algorithm)-----------%
j=0;
for t=0:N-1
if t<j
xn(j+1)=xn(j+1)+xn(t+1);
xn(t+1)=xn(j+1)-xn(t+1);
xn(j+1)=xn(j+1)-xn(t+1);
end
k=N/2;
while k<=j
j=j-k;k=k/2;
end
j=j+k;
end
%---------------FFT MAIN FUNCTION---------------------%
le=1;
L=log2(N);
for m=1:L
lei=le;
le=le*2;
u=exp(0);
w=exp(-pi*i/lei);
for j=0:lei-1
for k=j:le:N-1
p=k+lei;
r=xn(p+1)*u;
xn(p+1)=xn(k+1)-r;
xn(k+1)=xn(k+1)+r;
end
u=u*w;
end
end
XK=xn;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?