窗外的知了叽叽喳喳叫个不停,屋里温度应该有30°,伏天的日子难过啊!

频率域的方法来计算圆周移位

代码:

子函数的

  1. function y = cirshftf(x, m, N)
  2. %% -----------------------------------------------------------------------
  3. % Circular shift of m samples wrt size N in sequence x: (freq domain)
  4. % ---------------------------------------------------------------------
  5. % y = cirshftf(x, m, N)
  6. % y : output sequence containing the circular shift
  7. % x : input sequence of length <= N
  8. % m : sample shift
  9. % N : size of circular buffer
  10. % Method : y(n) = idft( dft(x(n)) * WN ^ (mk))
  11.  
  12. % if m is a scalar then y is a sequence (row vector)
  13. % if m is a vector then y is a matrix, each row is a circular shift
  14. % in x corresponding to entries in vector m
  15. % M and x should not be matrices
  16.  
  17. if length(x)>N
  18. error('N must >= length(x)' )
  19. end
  20.  
  21. x = [x zeros(1, N-length(x))];
  22. k = [0:1:N-1];
  23.  
  24. WN = exp(-j*2*pi/N);
  25. mk = m*k;
  26.  
  27. y = real(idft( dft(x, N) .* ( WN .^ (mk) ), N ));

  主函数的

  1. %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. %% Output Info about this m-file
  3. fprintf('\n***********************************************************\n');
  4. fprintf(' <DSP using MATLAB> Problem 5.20 \n\n');
  5.  
  6. banner();
  7. %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  8.  
  9. % ---------------------------------------------------------------------------------
  10. % circular shift
  11. % method 1 : cirshftt function, time domain
  12. % method 2 : cirshftf function, freq domain
  13. %
  14. % ---------------------------------------------------------------------------------
  15. n = [0:10];
  16. x = [5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4]; % N=11 sequence
  17.  
  18. m1 = -5; N1 = 12;
  19. n1 = [0:N1-1];
  20.  
  21. m2 = 8; N2 = 15;
  22. n2 = [0:N2-1];
  23.  
  24. % -----------------------------------------------------
  25. % 1st way to get circular shift---time domain
  26. % -----------------------------------------------------
  27. y1_1 = cirshftt(x, m1, N1);
  28. y2_1 = cirshftt(x, m2, N2);
  29.  
  30. % --------------------------------------------------------
  31. % 2rd way to get circular shift --- freq domain
  32. % --------------------------------------------------------
  33. y1_2 = cirshftf(x, m1, N1);
  34. y2_2 = cirshftf(x, m2, N2);
  35.  
  36. figure('NumberTitle', 'off', 'Name', 'P5.20.a x(n) and its cir shift')
  37. set(gcf,'Color','white');
  38. subplot(3,1,1); stem(n, x);
  39. xlabel('n'); ylabel('x(n)');
  40. title('x(n), N=11'); grid on;
  41. subplot(3,1,2); stem(n1, y1_1);
  42. %axis([-N/2, N/2, -0.5, 50.5]);
  43. xlabel('n'); ylabel('y(n)');
  44. title('TIME domain circular shift x(n), m=-5, N=12'); grid on;
  45. subplot(3,1,3); stem(n1, y1_2);
  46. xlabel('n'); ylabel('y(n)');
  47. title('FREQ domain circular shift x(n), m=-5, N=12'); grid on;
  48. axis([0, N1, 0, 6]);
  49.  
  50. figure('NumberTitle', 'off', 'Name', 'P5.20.b x(n) and its cir shift')
  51. set(gcf,'Color','white');
  52. subplot(3,1,1); stem(n, x);
  53. xlabel('n'); ylabel('x(n)');
  54. title('x(n), N=11'); grid on;
  55. subplot(3,1,2); stem(n2, y2_1);
  56. %axis([-N/2, N/2, -0.5, 50.5]);
  57. xlabel('n'); ylabel('y(n)');
  58. title('TIME domain circular shift x(n), m=8, N=15'); grid on;
  59. subplot(3,1,3); stem(n2, y2_2);
  60. xlabel('n'); ylabel('y(n)');
  61. title('FREQ domain circular shift x(n), m=8, N=15'); grid on;
  62. axis([0, N2, 0, 6]);

  运行结果:

《DSP using MATLAB》Problem 5.20的更多相关文章

  1. 《DSP using MATLAB》Problem 6.20

    先放子函数: function [C, B, A, rM] = dir2fs_r(h, r); % DIRECT-form to Frequency Sampling form conversion ...

  2. 《DSP using MATLAB》Problem 4.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. 《DSP using MATLAB》Problem 3.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  4. 《DSP using MATLAB》Problem 2.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  5. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  6. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  7. 《DSP using MATLAB》Problem 6.15

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  8. 《DSP using MATLAB》Problem 6.12

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  9. 《DSP using MATLAB》Problem 6.10

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

随机推荐

  1. laravel创建新的提交数据

    public function store() { $this->validate(request(),[ 'title'=>'required|string|max:100|min:10 ...

  2. learning at command AT+CIMI

    AT command AT+CIMI [Purpose]        Learning how to get the International Mobile Subscriber Identity ...

  3. TTL集成门电路工作原理和电压传输特性

    集成电路(Integrated Circuit 简称IC):即把电路中半导体器件,电阻,电容以及连线等制作在一块半导体基片上构成一个完整的电路,并封装到一个管壳内 集成电路的有点:体积小,重量轻,可靠 ...

  4. session和cokkie的区别与作用

    session在计算机中,尤其是在网络应用中,称为“会话机制”,Session对象存储特定用户会话所需的属性及配置信息,这样,当用户在应用程序的web页之间跳转时,存储在session对象中的变量将不 ...

  5. JavaScript示例

    <!DOCTYPE html> <html> <head> <title>单击按钮事件示例</title> <script langu ...

  6. IDEA中自动生成serialVersionUID

    File  >>  Setting  >>  Inspections  >>  serializable 勾选上后,光标放在实现Serializable接口的类名上 ...

  7. spoon 更新数据

    一个小需求,被要求使用spoon 来同步数据 主要流程为: 1.查询A库未同步数据 id 2.根据步骤1查到的id,作为条件更新B库数据 3.更新B库数据成功则更改库A中的数据状态为已同步. 4.添加 ...

  8. jetty域证书更新

    服务器:centos6.6 1.从正确的.pfx文件中导出.pem认证文件 #openssl pkcs12 -in example.pfx -nodes -out server.pem pfx文件可以 ...

  9. 解决Invalid bound statement (not found): com.cqupt.ssm.dao.UserDao.queryMenu问题

    今天写项目时多加了个查询菜品的方法报错: Invalid bound statement (not found): com.cqupt.ssm.dao.UserDao.queryMenu 大概意思是找 ...

  10. HIVE点滴:group by和distinct语句的执行顺序

    同一条语句之中,如果同时有group by和distinct语句,是先group by后distinct,还是先distinct后group by呢? 先说结论:先group by后distinct. ...