代码:

  1. %% ------------------------------------------------------------------------
  2. %% Output Info about this m-file
  3. fprintf('\n***********************************************************\n');
  4. fprintf(' <DSP using MATLAB> Exameple 9.6 \n\n');
  5.  
  6. time_stamp = datestr(now, 31);
  7. [wkd1, wkd2] = weekday(today, 'long');
  8. fprintf(' Now is %20s, and it is %7s \n\n', time_stamp, wkd2);
  9. %% ------------------------------------------------------------------------
  10.  
  11. n = 0:2048; k1 = 256; k2 = k1+32; m = 0:(k2-k1);
  12.  
  13. %% -----------------------------------------------------------------
  14. %% Plot
  15. %% -----------------------------------------------------------------
  16. Hf1 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
  17. 'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
  18. 'NumberTitle', 'off', 'Name', 'Exameple 9.6');
  19. set(gcf,'Color','white');
  20.  
  21. TF = 10;
  22. % (a) Original singal
  23. x = cos(0.125*pi*n);
  24. subplot(2, 2, 1);
  25. Ha = stem(m, x(m+k1+1), 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
  26. set(Ha, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
  27. title('Original Signal x(n)', 'fontsize', TF);
  28. set(gca, 'xtick', [0, 16, 32]);
  29. set(gca, 'ytick', [-1, 0, 1]);
  30.  
  31. % (b) Sample rate conversion by 3/2: I = 3, D = 2
  32. I = 3; D = 2; [y, h] = resample(x, I, D);
  33. fprintf('\n The Length of filter is %d , and length of y is %d \n', length(h), length(y) );
  34.  
  35. subplot(2, 2, 2);
  36. Hb = stem(m, y(m+k1*I/D+1), 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
  37. set(Hb, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
  38. title('Sample rate I/D: I = 3, D = 2 ', 'fontsize', TF);
  39. set(gca, 'xtick', [0, 16, 24, 32]);
  40. set(gca, 'ytick', [-1, 0, 1]);
  41.  
  42. % (c) Sample rate conversion by 3/4: I = 3, D = 4
  43. I = 3; D = 4; [y, h] = resample(x, I, D);
  44. fprintf('\n The Length of filter is %d , and length of y is %d \n', length(h), length(y) );
  45.  
  46. subplot(2, 2, 3);
  47. Hc = stem(m, y(m+k1*I/D+1), 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
  48. set(Hc, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
  49. title('Sample rate I/D: I = 3, D = 4 ', 'fontsize', TF);
  50. set(gca, 'xtick', [0, 12, 16, 32]);
  51. set(gca, 'ytick', [-1, 0, 1]);
  52.  
  53. % (d) Sample rate conversion by 5/8: I = 5, D = 8
  54. I = 5; D = 8; [y, h] = resample(x, I, D);
  55. fprintf('\n The Length of filter is %d , and length of y is %d \n', length(h), length(y) );
  56.  
  57. subplot(2, 2, 4);
  58. Hd = stem(m, y(m+k1*I/D+1), 'filled'); axis([-1, 33, -1.1, 1.1]); grid on;
  59. set(Hd, 'markersize', 2); xlabel('n'); ylabel('Amplitude');
  60. title('Sample rate I/D: I = 5, D = 8 ', 'fontsize', TF);
  61. set(gca, 'xtick', [0, 10, 16, 32]);
  62. set(gca, 'ytick', [-1, 0, 1]);

  运行结果:

三种不同采样率情况下对应的滤波器长度61、81、161是如何算出来的,我现在还不清楚,有知道的博友不吝赐教。在这里先谢谢了。

第1个采样率用3/2(大于1)转换,总体效果表现为插值。所得信号在一个周期内有16×3/2=24个采样点。

另外两个采样率变换因子都小于1,总体效果就表现为抽样,相应的一个周期内分别有16×3/4=12、16×5/8=10个采样点。

《DSP using MATLAB》示例 Example 9.6的更多相关文章

  1. DSP using MATLAB 示例Example3.21

    代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*a ...

  2. DSP using MATLAB 示例 Example3.19

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...

  3. DSP using MATLAB示例Example3.18

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...

  4. DSP using MATLAB 示例Example3.23

    代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...

  5. DSP using MATLAB 示例Example3.22

    代码: % Discrete-time Signal x2(n) Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nT ...

  6. DSP using MATLAB 示例Example3.17

  7. DSP using MATLAB示例Example3.16

    代码: b = [0.0181, 0.0543, 0.0543, 0.0181]; % filter coefficient array b a = [1.0000, -1.7600, 1.1829, ...

  8. DSP using MATLAB 示例 Example3.15

    上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figur ...

  9. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

  10. DSP using MATLAB 示例 Example3.12

    用到的性质 代码: n = -5:10; x = sin(pi*n/2); k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , ...

随机推荐

  1. MySQL Order By Rand()效率分析

    最近研究了一下MYSQL的随机抽取实现方法.举个例子,要从tablename表中随机提取一条记录,大家一般的写法就是:SELECT * FROM tablename ORDER BY RAND() L ...

  2. Android显示框架:自定义View实践之绘制篇

    文章目录 一 View 二 Paint 2.1 颜色处理 2.2 文字处理 2.3 特殊处理 三 Canvas 3.1 界面绘制 3.2 范围裁切 3.3 集合变换 四 Path 4.1 添加图形 4 ...

  3. 浏览器DOM操作

    HTML Node 节点 常用API 高效遍历 DOM Repaint and reflow 插入大量内容避免重绘和回流 style 样式操作 DOM事件 HTML - innerHTML:内部HTM ...

  4. Python+Opencv进行识别相似图片

    http://blog.csdn.net/feimengjuan/article/details/51279629

  5. 1-16-2 LVM管理和ssm存储管理器使用&磁盘配额

    ssm存储管理器使用&磁盘配额 ssm存储管理器使用 系统存储管理器的使用 系统存储管理器(又称ssm,即system-storage-manager),是RHEL7/CentOS7新增的功能 ...

  6. IOS-OC 编码建议

    “神在细节之中” Objective-C 是 C 语言的扩展,增加了动态类型和面对对象的特性.它被设计成具有易读易用的,支持复杂的面向对象设计的编程语言.它是 Mac OS X 以及 iPhone 的 ...

  7. 利用expect和sshpass完美非交互性执行远端命令

    yum install expect -y expect 参考:http://blog.csdn.net/snow_114/article/details/53245466 yum install s ...

  8. MySQL20个经典面试题

    MySQL20个经典面试题 Part2:经典题目 1.MySQL的复制原理以及流程 基本原理流程,3个线程以及之间的关联: 2.MySQL中myisam与innodb的区别,至少5点 (1).问5点不 ...

  9. certbot以standalone方式新建密钥

    下载:wget https://dl.eff.org/certbot-auto 授权:chmod a+x ./certbot-auto 快捷命令 ./certbot-auto certonly --t ...

  10. C++设计模式之-外观模式

    意图: 为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一系统更加容易使用. 适用性: 1.在设计初期阶段,应该要有意识的将不同的两个层分离,比如经典的三层架构,就需要 ...