请选择 进入手机版 | 继续访问电脑版

Hello Mat

 找回密码
 立即注册
查看: 5588|回复: 0

信号 DCT、FFT 开源代码

[复制链接]

1294

主题

1520

帖子

110

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22633
发表于 2017-8-5 10:59:44 | 显示全部楼层 |阅读模式
信号离散余弦变换DCT、傅里叶变换FFT 底层代码实现
  1. function x=f_fft(y,m)
  2. if nargin ==1 | length(y)>2^m               %Adjusting the Input Arguments.
  3.     m=log2(length(y));
  4.     m=floor(m);
  5. end
  6. y=y(1:2^m);
  7. Dec_order=0:(2^m)-1;                        % Making a decimal order from bit reversed order
  8. reversed_order=digitrevorder(Dec_order, 2); % copying original signal y to x in reversed bit order
  9. for index=1:2^m
  10.     x(index)=y(reversed_order(index)+1);
  11. end
  12. for state=1:m                               % state is the each multiplying step
  13.       for kN=1:2^(state-1)                  % there are (2^(state-1) different W for each state
  14.         N=2^state;
  15.         k=kN-1;                             % in real equation actually k=kn
  16.         W(kN)=exp(-j*2*pi*k/N);
  17.     end                                     % end of W
  18.     index=1;                                % index counter of the equation number
  19.     diff=2^(state-1);
  20.     kN=1;                                   % index counter of the W   
  21.     while (index <= (2^m))                  % there are 2^m equation     
  22.         for plus=1:2^(state-1)              % plus is the number of addition in a seq.
  23.             U(index)=x(index)+W(kN)*x(index+diff);
  24.             index=index+1;
  25.             if kN < 2^(state-1)
  26.                 kN=kN+1;
  27.             else
  28.                 kN=1;
  29.             end     
  30.         end                                 % end of "for loop" of equations for additon
  31.         
  32.           for minus=1:2^(state-1)
  33.             U(index)=x(index-diff)-W(kN)*x(index);
  34.             index=index+1;
  35.             if kN < 2^(state-1)
  36.                 kN=kN+1;
  37.             else
  38.                 kN=1;
  39.             end     
  40.           end                               % end of "for loop" of equations for subtraction
  41.         
  42.     end                                
  43.     for index=1:2^m
  44.         x(index)=U(index);
  45.     end                                     % end of "for loop" -- copying array to pass next state

  46. end                                         % end of "for loop" of state value
  47. x;                                          % x is the DFT of the signal y for the number of 2^m points
复制代码
代码分享:http://pan.baidu.com/s/1c2dBzoO


算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-4-18 09:05 , Processed in 0.202070 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表