代码:

  1. % The following funciton computes the filter
  2. % coefficients shown in Table 6.2
  3. b = firpm(30, [0, 0.3, 0.5, 1], [1, 1, 0, 0]);
  4. w = [0:500]*pi/500; H = freqz(b, 1, w);
  5. magH = abs(H); magHdb = 20*log10(magH);
  6.  
  7. % 16-bit word-length quantization
  8. N1 = 15; [bhat1, L1, B1] = QCoeff(b, N1);
  9. TITLE1 = sprintf('%i-bits (1+%i+%i) ', N1+1, L1, B1);
  10. %bhat1 = bahat(1, :); ahat1 = bahat(2, :);
  11. Hhat1 = freqz(bhat1, 1, w); magHhat1 = abs(Hhat1);
  12. magHhat1db = 20*log10(magHhat1); zhat1 = roots(bhat1);
  13.  
  14. % 8-bit word-length quantization
  15. N2 = 7; [bhat2, L2, B2] = QCoeff(b, N2);
  16. TITLE2 = sprintf('%i-bits (1+%i+%i) ', N2+1, L2, B2);
  17. %bhat2 = bahat(1, :); ahat2 = bahat(2, :);
  18. Hhat2 = freqz(bhat2, 1, w); magHhat2 = abs(Hhat2);
  19. magHhat2db = 20*log10(magHhat2); zhat2 = roots(bhat2);
  20.  
  21. % Comparison of Magnitude Plots
  22. Hf_1 = figure('paperunits', 'inches', 'paperposition', [0, 0, 6, 5], 'NumberTitle', 'off', 'Name', 'Exameple 6.29');
  23. %figure('NumberTitle', 'off', 'Name', 'Exameple 6.26a')
  24. set(gcf,'Color','white');
  25.  
  26. % Comparison of Log-Magnitude Response: 16 bits
  27. subplot(2, 2, 1); plot(w/pi, magHdb, 'g', 'linewidth', 1.5); axis([0, 1, -80, 5]);
  28. hold on; plot(w/pi, magHhat1db, 'r', 'linewidth', 1); hold off;
  29. xlabel('Digital Frequency in \pi units', 'fontsize', 10);
  30. ylabel('Decibels', 'fontsize', 10); grid on;
  31. title(['Log-mag Plot: ', TITLE1], 'fontsize', 10, 'fontweight', 'bold');
  32.  
  33. % Comparison of Pole-Zero Plots: 16 bits
  34. subplot(2, 2, 3); [HZ, HP, Hl] = zplane([b], [1]); axis([-2, 2, -2, 2]); hold on;
  35. set(HZ, 'color', 'g', 'linewidth', 1, 'markersize', 4);
  36. set(HP, 'color', 'g', 'linewidth', 1, 'markersize', 4);
  37. plot(real(zhat1), imag(zhat1), 'r+', 'linewidth', 1); grid on;
  38. title(['PZ Plot: ' TITLE1], 'fontsize', 10, 'fontweight', 'bold'); hold off;
  39.  
  40. % Comparison of Log-Magnitude Response: 8 bits
  41. subplot(2, 2, 2); plot(w/pi, magHdb, 'g', 'linewidth', 1.5); axis([0, 1, -80, 5]);
  42. hold on; plot(w/pi, magHhat2db, 'r', 'linewidth', 1); hold off;
  43. xlabel('Digital Frequency in \pi units', 'fontsize', 10);
  44. ylabel('Decibels', 'fontsize', 10); grid on;
  45. title(['Log-mag Plot: ', TITLE2], 'fontsize', 10, 'fontweight', 'bold');
  46.  
  47. % Comparison of Pole-Zero Plots: 8 bits
  48. subplot(2, 2, 4); [HZ, HP, Hl] = zplane([b], [1]); axis([-2, 2, -2, 2]); hold on;
  49. set(HZ, 'color', 'g', 'linewidth', 1, 'markersize', 4);
  50. set(HP, 'color', 'g', 'linewidth', 1, 'markersize', 4);
  51. plot(real(zhat2), imag(zhat2), 'r+', 'linewidth', 1); grid on;
  52. title(['PZ Plot: ' TITLE2], 'fontsize', 10, 'fontweight', 'bold'); hold off;

运行结果:

《DSP using MATLAB》示例Example6.29的更多相关文章

  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 ...

随机推荐

  1. Java虚拟机组成详解

    导读:详细而深入的总结,是对知识“豁然开朗”之后的“刻骨铭心”,想忘记都难. Java虚拟机(Java Virtual Machine)下文简称jvm,上一篇我们对jvm有了大体的认识,进入本文之后我 ...

  2. Fedora安装opengl

    Fedora和Ubuntu下安装OpenGL开发环境配置(我整理的)OpenGL开发库的详细介绍fedora23 安装OpenGL 开发OpenGL工程需要3个库文件和对应的头文件:libglut.s ...

  3. Centos服务器被挂马的一次抓马经历

    转载:http://blog.csdn.net/qq_21439971/article/details/54631440 今天早上五点,收到监控宝的警告短信,说是网站M无法访问了.睡的正香,再说网站所 ...

  4. ctci1.8

    bool isSub(string str0, string str1){     if(str0.length() != str1.length())         return false;   ...

  5. spring mvc: json练习

    spring mvc: json练习 本例需要用到的json包: 如下: jackson-databind jackson-core jackson-annotations <!-- https ...

  6. 开启Tomcat APR运行模式,优化并发性能

    Tomcat支持三种接收请求的处理方式:BIO.NIO.APR 1>.BIO模式:阻塞式I/O操作,表示Tomcat使用的是传统JavaI/O操作(即Java.io包及其子包).Tomcat7以 ...

  7. linux五大搜索命令学习

    五大搜索命令学习 分别解释locate,find,which,whereis,grep 五大linux搜索命令 locate 解释:由man手册可以看出,locate查找就是根据文件名进行查找,只是依 ...

  8. 简明 Nginx Location Url 配置笔记

    基本配置 为了探究nginx的url配置规则,当然需要安装nginx.我使用了vagrant创建了一个虚拟环境的ubuntu,通过apt-get安装nginx.这样就不会污染mac的软件环境.通过vr ...

  9. hdu 5818 Joint Stacks (优先队列)

    Joint Stacks Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  10. 数据存储-- Core Data的使用(二)

    一.基础概念深入 1.NSManagedObjectContext 被管理数据上下文就像便笺簿 当从数据持久层获取数据时,相当于把这些临时的数据拷贝写在便笺簿上,然后就可以随心所欲的修改这些值. 通过 ...