代码:

  1. %% ------------------------------------------------------------------------
  2. %% Output Info about this m-file
  3. fprintf('\n***********************************************************\n');
  4. fprintf(' <DSP using MATLAB> Problem 8.21 \n\n');
  5.  
  6. banner();
  7. %% ------------------------------------------------------------------------
  8.  
  9. Fp = 3.2; % analog passband freq in kHz
  10. Fs = 3.8; % analog stopband freq in kHz
  11. fs = 8; % sampling rate in kHz
  12.  
  13. % -------------------------------
  14. % ω = ΩT = 2πF/fs
  15. % Digital Filter Specifications:
  16. % -------------------------------
  17. %wp = 2*pi*Fp/fs; % digital passband freq in rad/sec
  18. wp = Fp;
  19. %ws = 2*pi*Fs/fs; % digital stopband freq in rad/sec
  20. ws = Fs;
  21. Rp = 0.5; % passband ripple in dB
  22. As = 45; % stopband attenuation in dB
  23.  
  24. Ripple = 10 ^ (-Rp/20) % passband ripple in absolute
  25. Attn = 10 ^ (-As/20) % stopband attenuation in absolute
  26.  
  27. % Analog prototype specifications: Inverse Mapping for frequencies
  28. T = 1; % set T = 1
  29. OmegaP = wp/T; % prototype passband freq
  30. OmegaS = ws/T; % prototype stopband freq
  31.  
  32. % Analog Chebyshev-1 Prototype Filter Calculation:
  33. [cs, ds] = afd_chb1(OmegaP, OmegaS, Rp, As);
  34.  
  35. % Calculation of second-order sections:
  36. fprintf('\n***** Cascade-form in s-plane: START *****\n');
  37. [CS, BS, AS] = sdir2cas(cs, ds)
  38. fprintf('\n***** Cascade-form in s-plane: END *****\n');
  39.  
  40. % Calculation of Frequency Response:
  41. [db_s, mag_s, pha_s, ww_s] = freqs_m(cs, ds, 8);
  42.  
  43. % Calculation of Impulse Response:
  44. [ha, x, t] = impulse(cs, ds);
  45.  
  46. % Impulse Invariance Transformation:
  47. [b, a] = imp_invr(cs, ds, T); [C, B, A] = dir2par(b, a)
  48.  
  49. % Calculation of Frequency Response:
  50. [db, mag, pha, grd, ww] = freqz_m(b, a);
  51.  
  52. %% -----------------------------------------------------------------
  53. %% Plot
  54. %% -----------------------------------------------------------------
  55. figure('NumberTitle', 'off', 'Name', 'Problem 8.21 Analog Chebyshev-I lowpass')
  56. set(gcf,'Color','white');
  57. M = 1.0; % Omega max
  58.  
  59. subplot(2,2,1); plot(ww_s, mag_s/T); grid on; %axis([-10, 10, 0, 1.2]);
  60. xlabel(' Analog frequency in kHz units'); ylabel('|H|'); title('Magnitude in Absolute');
  61. set(gca, 'XTickMode', 'manual', 'XTick', [-8, -3.8, -3.2, 0, 3.2, 3.8, 8]);
  62. set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.006, 0.94, 1]);
  63.  
  64. subplot(2,2,2); plot(ww_s, db_s); grid on; %axis([0, M, -50, 10]);
  65. xlabel('Analog frequency in kHz units'); ylabel('Decibels'); title('Magnitude in dB ');
  66. set(gca, 'XTickMode', 'manual', 'XTick', [-8, -3.8, 0, 3.2, 3.8, 8]);
  67. set(gca, 'YTickMode', 'manual', 'YTick', [-45, -1, 0]);
  68. set(gca,'YTickLabelMode','manual','YTickLabel',['45';' 1';' 0']);
  69.  
  70. subplot(2,2,3); plot(ww_s, pha_s/pi); grid on; axis([-10, 10, -1.2, 1.2]);
  71. xlabel('Analog frequency in kHz nuits'); ylabel('radians'); title('Phase Response');
  72. set(gca, 'XTickMode', 'manual', 'XTick', [-8, -3.8, 0, 3.2, 3.8, 8]);
  73. set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]);
  74.  
  75. subplot(2,2,4); plot(t, ha); grid on; %axis([0, 30, -0.05, 0.25]);
  76. xlabel('time in seconds'); ylabel('ha(t)'); title('Impulse Response');
  77.  
  78. figure('NumberTitle', 'off', 'Name', 'Problem 8.21 Digital Chebyshev-I lowpass')
  79. set(gcf,'Color','white');
  80. M = 2; % Omega max
  81.  
  82. subplot(2,2,1); plot(ww/pi, mag); axis([0, M, 0, 1.2]); grid on;
  83. xlabel(' frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
  84. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.8, 0.95, M]);
  85. set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0056, 0.9441, 1]);
  86.  
  87. subplot(2,2,2); plot(ww/pi, pha/pi); axis([0, M, -1.1, 1.1]); grid on;
  88. xlabel('frequency in \pi nuits'); ylabel('radians in \pi units'); title('Phase Response');
  89. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.8, 0.95, M]);
  90. set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]);
  91.  
  92. subplot(2,2,3); plot(ww/pi, db); axis([0, M, -30, 10]); grid on;
  93. xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB ');
  94. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.8, 0.95, M]);
  95. set(gca, 'YTickMode', 'manual', 'YTick', [-60, -45, -1, 0]);
  96. set(gca,'YTickLabelMode','manual','YTickLabel',['60';'45';' 1';' 0']);
  97.  
  98. subplot(2,2,4); plot(ww/pi, grd); grid on; %axis([0, M, 0, 35]);
  99. xlabel('frequency in \pi units'); ylabel('Samples'); title('Group Delay');
  100. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.8, 0.95, M]);
  101. %set(gca, 'YTickMode', 'manual', 'YTick', [0:5:35]);
  102.  
  103. figure('NumberTitle', 'off', 'Name', 'Problem 8.21 Pole-Zero Plot')
  104. set(gcf,'Color','white');
  105. zplane(b,a);
  106. title(sprintf('Pole-Zero Plot'));
  107. %pzplotz(b,a);
  108.  
  109. % ----------------------------------------------
  110. % Calculation of Impulse Response
  111. % ----------------------------------------------
  112. figure('NumberTitle', 'off', 'Name', 'Problem 8.21 Imp & Freq Response')
  113. set(gcf,'Color','white');
  114. t = [0:0.01:60]; subplot(2,1,1); impulse(cs,ds,t); grid on; % Impulse response of the analog filter
  115. axis([0,60,-0.5,1.0]);hold on
  116.  
  117. n = [0:1:60/T]; hn = filter(b,a,impseq(0,0,60/T)); % Impulse response of the digital filter
  118. stem(n*T,hn); xlabel('time in sec'); title (sprintf('Impulse Responses T=%2d',T));
  119. hold off
  120.  
  121. % Calculation of Frequency Response:
  122. [dbs, mags, phas, wws] = freqs_m(cs, ds, 2*pi/T); % Analog frequency s-domain
  123.  
  124. [dbz, magz, phaz, grdz, wwz] = freqz_m(b, a); % Digital z-domain
  125.  
  126. %% -----------------------------------------------------------------
  127. %% Plot
  128. %% -----------------------------------------------------------------
  129.  
  130. subplot(2,1,2); plot(wws/(2*pi),mags/T,'b+', wwz/(2*pi*T),magz,'r'); grid on;
  131.  
  132. xlabel('frequency in Hz'); title('Magnitude Responses'); ylabel('Magnitude');
  133.  
  134. text(-0.8,0.15,'Analog filter'); text(0.6,1.05,'Digital filter');

  运行结果:

通带、阻带指标

模拟Chebyshev-1型低通系统函数,串联形式系数

脉冲响应不变法,转换成数字低通,系统函数直接形式系数

模拟Chebyshev-1型低通,幅度谱、相位谱和脉冲响应

数字Chebyshev-1型低通,幅度谱、相位谱和群延迟

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

  1. 《DSP using MATLAB》Problem 6.21

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

  2. 《DSP using MATLAB》Problem 5.21

    证明: 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  3. 《DSP using MATLAB》Problem 4.21

    快到龙抬头,居然下雪了,天空飘起了雪花,温度下降了近20°. 代码: %% -------------------------------------------------------------- ...

  4. 《DSP using MATLAB》Problem 3.21

    模拟信号经过不同的采样率进行采样后,得到不同的数字角频率,如下: 三种Fs,采样后的信号的谱 重建模拟信号,这里只显示由第1种Fs=0.01采样后序列进行重建,采用zoh.foh和spline三种方法 ...

  5. 《DSP using MATLAB》Problem 7.27

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

  6. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

  7. 《DSP using MATLAB》Problem 7.24

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

  8. 《DSP using MATLAB》Problem 7.23

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

  9. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. 论文阅读笔记---ShuffleNet V1

    01 ShuffleNet V1要解决什么问题 为算力有限的嵌入式场景下专门设计一个高效的神经网络架构. 02 亮点 使用了两个新的操作:pointwise group convolution和cha ...

  2. java Future && Guava Future

    ### java future Runnable的任务是没有返回值,也不能抛出异常的java.util.concurrent.Callable接口,可以返回一个对象或者抛出异常 使用jdk的这种方式提 ...

  3. java 多项式

    /****************************************************************************** * Compilation: javac ...

  4. RabbitMQ学习第一记:用java连接RabbitMQ

    1.什么是RabbitMQ MQ(Message Queue):消息队列,是服务端设计的一个可以存储大量消息的队列,并提供客户端操作队列的方法:生产队列(向队列中添加数据).消费队列(从队列中取数据) ...

  5. JVM之类加载过程

    # 类的生命周期 1. 加载 loading2. 验证 verification3. 准备 preparation4. 解析 resoluation5. 初始化 initialization6. 使用 ...

  6. [转]MySQL InnoDB引擎索引长度受限怎么办

    mysql> CREATE TABLE `tb` (-> `a` varchar(255) DEFAULT NULL,-> `b` varchar(255) DEFAULT NULL ...

  7. (转)Android开发把项目打包成apk

    转:http://blog.csdn.net/luoyin22/article/details/7862742 做完一个Android项目之后,如何才能把项目发布到Internet上供别人使用呢?我们 ...

  8. CygWin、MinGw和Msys的区别

    做了6年的Windows C++,觉得已经没什么挑战力:而且Windows C++已经没落,不得不转Linux C++: 习惯了Windows的界面,习惯了傻瓜式的VS IDE,现在遇到Linux命令 ...

  9. 数据库连接JDBC

    #=======================mysql============================= #jdbc.driverClassName=com.mysql.jdbc.Driv ...

  10. Jodd - Java界的瑞士军刀轻量级工具包!

    Jodd介绍 Jodd是对于Java开发更便捷的开源迷你框架,包含工具类.实用功能的集合,总包体积不到1.7M. Jodd构建于通用场景使开发变得简单,但Jodd并不简单!它能让你把事情做得更好,实现 ...