matlab bitrevorder,求MATLAB写的FFT源程序!

function  X = radix2(x,inverse)

x = [1 1 1 1 0 0 0 0 ];

inverse = 1;

switch inverse

case 1

xcheck=x;

p=nextpow2(length(x));

x=[x zeros(1,(2^p)-length(x))];

N=length(x);

M=N/2;                                                                     % Index Helping for Controlling range of indices of the Butterfly at Each Stage (Shrinking)

for stage=1:log2(N);                                                       % No of times decimation has to occur

for index=0:(N/(2^(stage-1))):(N-1);                              % Adjusting the index variations of the butterfly in each stage

for n=0:M-1;                                                  % Within a stage, for a given index (single) as reference, develop a local Butterfly Index

a=x(n+index+1)+ x(n+index+M+1);

AA = exp((-j*(2*pi)/N)*(2^(stage-1))*(n));

a = fi(AA);

b=(x(n+index+1)- x(n+index+M+1)).* AA;

x(n+1+index)=a;

x(n+M+1+index)=b;                                    % In place Computation

end;

end;

M=M/2;                                                                     % Used for creating Butterfly Pairs (INDEXing the wings) (Shrinkage)

end;

X=bitrevorder(x);                                                          % Bit reversing X[k] to obtain X[k] 0

% Ycheck=fft(xcheck,N)

% Cross Check the answer using inbuilt FFT

case 2

xcheck=x;

x=x';

p=nextpow2(length(x));

x=[x zeros(1,(2^p)-length(x))];

N=length(x);

M=N/2;                                                                     % Index Helping for Controlling range of indices of the Butterfly at Each Stage (Shrinking)

for stage=1:log2(N);                                                       % No of times decimation has to occur

for index=0:(N/(2^(stage-1))):(N-1);                              % Adjusting the index variations of the butterfly in each stage

for n=0:M-1;                                                  % Within a stage, for a given index (single) as reference, develop a local Butterfly Index

a=x(n+index+1)+ x(n+index+M+1);

b=(x(n+index+1)- x(n+index+M+1)).*exp((-j*(2*pi)/N)*(2^(stage-1))*(n));

x(n+1+index)=a;

x(n+M+1+index)=b;                                    % In place Computation

end;

end;

M=M/2;                                                                     % Used for creating Butterfly Pairs (INDEXing the wings) (Shrinkage)

end;

X=bitrevorder(x) ;                                                         % Bit reversing X[k] to obtain X[k] 0

X = X'/N

end

% Ycheck=ifft(xcheck,N)

% Cross Check the answer using inbuilt IFFT

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值