IFFT 的实现

前些天给出了FFT的实现,如今给出IFFT(inverse FFT)的实现

基于IFFT 算法。对FFT的核心程序稍作改动就可以 : )

%%***************************************************************************************
% code writer : EOF
% code date : 2014.09.17
% e-mail : jasonleaster@gmail.com
% code file : IFFT_EOF.m
% Version : 1.0
%
% code purpose :
%
% It's time to finish my demo for DFT. I would like to share my code with
% someone who is interesting in DSP. If there is something wrong with my code,
% please touche me by e-mail. Thank you!
%
%%*************************************************************************************** clear all; %*************************************************
% The number of all the signal that our sensor got
%*************************************************
TotalSample = 8; % We assume that the preiod of the signal we generated is 'circle';
circle = TotalSample/2; %**************************************************************
% This varible is used for recording the signal which
% were processed by inverse-DFT in time domain
%**************************************************************
SignalInT = zeros(TotalSample,1); SignalInT_reversed = zeros(TotalSample,1);
%This varible is used for recording the signal which were processed by inverse-DFT in time domain OutPutSignal = zeros(TotalSample,1); OriginalSignal = zeros(TotalSample,1);
%This varible is used for recording the original signal that we got. %% initialize a square wave
for SampleNumber = -(TotalSample/2):(TotalSample/2)-1 if (mod(abs(SampleNumber),circle) < (circle/2))&&(SampleNumber>0) OriginalSignal((TotalSample/2)+1+SampleNumber) = 5; elseif (mod(abs(SampleNumber),circle) >= (circle/2))&&(SampleNumber>0) OriginalSignal((TotalSample/2)+1+SampleNumber) = 0; elseif (mod(abs(SampleNumber),circle) < (circle/2))&&(SampleNumber<0) OriginalSignal((TotalSample/2)+1+SampleNumber) = 0; elseif (mod(abs(SampleNumber),circle) >= (circle/2))&&(SampleNumber<0) OriginalSignal((TotalSample/2)+1+SampleNumber) = 5;
end
end InPutSignal = fft(OriginalSignal); % for testing TotalSample = size(InPutSignal,1); OutPutSignal_to_time = zeros(TotalSample,1); tmp = TotalSample - 1; %%***********************************************************************
% @Bits : describe how many bits should be used to make up the TotalSample
%%***********************************************************************
Bits = 0; while tmp > 0 %% floor (X) Return the largest integer not greater than X.
tmp = floor(tmp/2); Bits = Bits + 1;
end %*******************************************************************
% | | | |
% input X(n) | layer 3 |layer 2 |layer 1 | x(n) output
% | | | |
%
%
% @layyer : the number of layyer
% @SampleNumber: the start number of point which
% is going to do butter-fly operation.
% @pre_half : the pre_half point of current butter-fly
%***********************************************************************
for layyer = Bits:-1:1 for SampleNumber = 1 : 2^(layyer) : TotalSample for pre_half = SampleNumber:(SampleNumber+2^(layyer-1) -1) r = -get_r_in_Wn(pre_half-1,layyer,TotalSample,Bits); W_rN = exp(-2*pi*j*(r)/TotalSample) ; OutPutSignal_to_time(pre_half) = ...
0.5*(InPutSignal(pre_half) + ...
InPutSignal(pre_half + 2^(layyer-1))); OutPutSignal_to_time(pre_half + 2^(layyer-1)) = ...
0.5*W_rN *(InPutSignal(pre_half) - ...
InPutSignal(pre_half + 2^(layyer-1))); end
end InPutSignal = OutPutSignal_to_time;
end %******************************************
% Reverse the bits of output number
%******************************************
for SampleNumber = 1 : TotalSample ret = bit_reverse(SampleNumber - 1,Bits); OutPutSignal_to_time(SampleNumber) = InPutSignal(ret+1);
end

对照原始时间领域的输入信号和最后IFFT的输出信号,一致。于是IFFT实现成功

以后给出对应版本号的C 语言实现

wait for update : )

最新文章

  1. Android 高级面试题及答案
  2. Unity3D教程:茄子童萌會
  3. PHP不仅仅是PHP
  4. Linux性能检测命令 - vmstat
  5. bjfu1287字符串输出的大水题
  6. C# winform 若要在加载设计器前避免可能发生的数据丢失,必须纠正以下错误
  7. 如何将sql server数据库转化成sqlite数据库
  8. 【转载】ABAP-如何读取内表的字段名称
  9. poj1724
  10. Hibernate配置文件的hbm2ddl.auto属性
  11. python学习------迭代器协议和生成器
  12. ONOS架构-系统组件
  13. bzoj3678 简单题
  14. hdu 1754解题报告 (代码+注释)
  15. [转] Compile、Make和Build的区别
  16. C语言发展历程及其保留字(关键字)——附:C语言标准文档
  17. 使用XML-RPC进行远程文件共享
  18. SecureCRT8.1下载+注册机+破解教程
  19. ParagraphFormat 对象【精品】
  20. SPOJ - TTM 主席树

热门文章

  1. PHP——基本使用(一)
  2. 如何利用CSS中的ime-mode用来控制页面上文本框中的全角/半角输入
  3. ubuntu部署java环境
  4. struts2特殊符号替换
  5. HDU_1166_敌兵布阵
  6. Python游戏开发:pygame游戏开发常用数据结构
  7. MySql学习笔记(四) —— 数据的分组
  8. kubeadmin 安装k8s集群
  9. videojs
  10. 用python写了一个猜年龄小游戏