下雨了,大风降温,一地树叶,终于进入冬季了

代码:

  1. %% ------------------------------------------------------------------------
  2. %% Output Info about this m-file
  3. fprintf('\n***********************************************************\n');
  4. fprintf(' <DSP using MATLAB> Problem 8.46.4 \n\n');
  5.  
  6. banner();
  7. %% ------------------------------------------------------------------------
  8.  
  9. % Digital Filter Specifications: Elliptic bandpass
  10. wsbp = [0.30*pi 0.60*pi]; % digital stopband freq in rad
  11. wpbp = [0.35*pi 0.50*pi]; % digital passband freq in rad
  12. Rp = 1.00; % passband ripple in dB
  13. As = 40; % stopband attenuation in dB
  14.  
  15. Ripple = 10 ^ (-Rp/20) % passband ripple in absolute
  16. Attn = 10 ^ (-As/20) % stopband attenuation in absolute
  17.  
  18. fprintf('\n*******Digital bandpass, Coefficients of DIRECT-form***********\n');
  19. [bbp, abp] = elipbpf(wpbp, wsbp, Rp, As)
  20. [C, B, A] = dir2cas(bbp, abp)
  21.  
  22. % Calculation of Frequency Response:
  23. [dbbp, magbp, phabp, grdbp, wwbp] = freqz_m(bbp, abp);
  24.  
  25. % ---------------------------------------------------------------
  26. % find Actual Passband Ripple and Min Stopband attenuation
  27. % ---------------------------------------------------------------
  28. delta_w = 2*pi/1000;
  29. Rp_bp = -(min(dbbp(ceil(wpbp(1)/delta_w+1):1:ceil(wpbp(2)/delta_w+1)))); % Actual Passband Ripple
  30.  
  31. fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp_bp);
  32.  
  33. As_bp = -round(max(dbbp(1:1:ceil(wsbp(1)/delta_w)+1))); % Min Stopband attenuation
  34. fprintf('\nMin Stopband attenuation is %.4f dB.\n\n', As_bp);
  35.  
  36. %% -----------------------------------------------------------------
  37. %% Plot
  38. %% -----------------------------------------------------------------
  39.  
  40. figure('NumberTitle', 'off', 'Name', 'Problem 8.46.4 Elliptic bp by elipbpf function')
  41. set(gcf,'Color','white');
  42. M = 1; % Omega max
  43.  
  44. subplot(2,2,1); plot(wwbp/pi, magbp); axis([0, M, 0, 1.2]); grid on;
  45. xlabel('Digital frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
  46. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.35, 0.5, 0.6, M]);
  47. set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.01, 0.8913, 1]);
  48.  
  49. subplot(2,2,2); plot(wwbp/pi, dbbp); axis([0, M, -100, 2]); grid on;
  50. xlabel('Digital frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB');
  51. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.35, 0.5, 0.6, M]);
  52. set(gca, 'YTickMode', 'manual', 'YTick', [-80, -40, -1, 0]);
  53. set(gca,'YTickLabelMode','manual','YTickLabel',['80'; '40';'1 ';' 0']);
  54.  
  55. subplot(2,2,3); plot(wwbp/pi, phabp/pi); axis([0, M, -1.1, 1.1]); grid on;
  56. xlabel('Digital frequency in \pi nuits'); ylabel('radians in \pi units'); title('Phase Response');
  57. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.35, 0.5, 0.6, M]);
  58. set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]);
  59.  
  60. subplot(2,2,4); plot(wwbp/pi, grdbp); axis([0, M, 0, 80]); grid on;
  61. xlabel('Digital frequency in \pi units'); ylabel('Samples'); title('Group Delay');
  62. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.35, 0.5, 0.6, M]);
  63. set(gca, 'YTickMode', 'manual', 'YTick', [0:20:80]);
  64.  
  65. figure('NumberTitle', 'off', 'Name', 'Problem 8.46.4 Pole-Zero Plot')
  66. set(gcf,'Color','white');
  67. zplane(bbp, abp);
  68. title(sprintf('Pole-Zero Plot'));
  69. %pzplotz(b,a);
  70.  
  71. % -----------------------------------------------------
  72. % method 3 elip function
  73. % -----------------------------------------------------
  74.  
  75. % Calculation of Elliptic filter parameters:
  76. [N, wn] = ellipord(wpbp/pi, wsbp/pi, Rp, As);
  77.  
  78. fprintf('\n ********* Elliptic Digital Bandpass Filter Order is = %3.0f \n', 2*N)
  79.  
  80. % Digital Elliptic Bandpass Filter Design:
  81. [bbp, abp] = ellip(N, Rp, As, wn)
  82.  
  83. [C, B, A] = dir2cas(bbp, abp)
  84.  
  85. % Calculation of Frequency Response:
  86. [dbbp, magbp, phabp, grdbp, wwbp] = freqz_m(bbp, abp);
  87.  
  88. % ---------------------------------------------------------------
  89. % find Actual Passband Ripple and Min Stopband attenuation
  90. % ---------------------------------------------------------------
  91. delta_w = 2*pi/1000;
  92. Rp_bp = -(min(dbbp(ceil(wpbp(1)/delta_w+1):1:ceil(wpbp(2)/delta_w+1)))); % Actual Passband Ripple
  93.  
  94. fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp_bp);
  95.  
  96. As_bp = -round(max(dbbp(1:1:ceil(wsbp(1)/delta_w)+1))); % Min Stopband attenuation
  97. fprintf('\nMin Stopband attenuation is %.4f dB.\n\n', As_bp);
  98.  
  99. %% -----------------------------------------------------------------
  100. %% Plot
  101. %% -----------------------------------------------------------------
  102.  
  103. figure('NumberTitle', 'off', 'Name', 'Problem 8.46.4 Elliptic bp by ellip function')
  104. set(gcf,'Color','white');
  105. M = 1; % Omega max
  106.  
  107. subplot(2,2,1); plot(wwbp/pi, magbp); axis([0, M, 0, 1.2]); grid on;
  108. xlabel('Digital frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
  109. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.35, 0.5, 0.6, M]);
  110. set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.01, 0.8913, 1]);
  111.  
  112. subplot(2,2,2); plot(wwbp/pi, dbbp); axis([0, M, -100, 2]); grid on;
  113. xlabel('Digital frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB');
  114. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.35, 0.5, 0.6, M]);
  115. set(gca, 'YTickMode', 'manual', 'YTick', [-80, -40, -1, 0]);
  116. set(gca,'YTickLabelMode','manual','YTickLabel',['80'; '40';'1 ';' 0']);
  117.  
  118. subplot(2,2,3); plot(wwbp/pi, phabp/pi); axis([0, M, -1.1, 1.1]); grid on;
  119. xlabel('Digital frequency in \pi nuits'); ylabel('radians in \pi units'); title('Phase Response');
  120. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.35, 0.5, 0.6, M]);
  121. set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]);
  122.  
  123. subplot(2,2,4); plot(wwbp/pi, grdbp); axis([0, M, 0, 100]); grid on;
  124. xlabel('Digital frequency in \pi units'); ylabel('Samples'); title('Group Delay');
  125. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.35, 0.5, 0.6, M]);
  126. set(gca, 'YTickMode', 'manual', 'YTick', [0:30:90]);

  运行结果:

看题目,是Elliptic型数字带通,设计指标,DB转换成绝对指标

Elliptic模拟低通原型阶数是4,使用elipbpf函数设计带通,系统函数直接形式和串联形式的系数如下,

幅度谱、相位谱和群延迟响应

零极点图

采用elip函数(MATLAB工具箱函数),设计带通,阶数是8阶,系统函数直接形式和串联形式的系数如下

幅度谱、相位谱和群延迟响应

给定通带、阻带衰减处的精确频带边界频率,我暂时不会计算,以后学会了再放图吧。

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

  1. 《DSP using MATLAB》Problem 7.13

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

  2. 《DSP using MATLAB》Problem 3.4

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

  3. 《DSP using MATLAB》Problem 8.45

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

  4. 《DSP using MATLAB》Problem 8.44

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

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

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

  8. 《DSP using MATLAB》Problem 7.24

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

  9. 《DSP using MATLAB》Problem 7.23

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

随机推荐

  1. 动态队列实现-----C语言

    /***************************************************** Author:Simon_Kly Version:0.1 Date: 20170520 D ...

  2. cd 命令行进入目标文件夹

    当我在默认路径中使用cd命令时,如果我要进入D:\mytext 文件夹,那么直接使用cd D:\mytext 是不行的 正确的使用是先使用d:进入D盘,然后再进入mytext文件夹

  3. python 多设备同时安装app包

    python  多设备同时安装app包 上代码 #!/usr/bin/env python # -*- encoding: utf-8 -*- import os import time from m ...

  4. 【hive 日期函数】Hive常用日期函数整理

    1.to_date:日期时间转日期函数 select to_date('2015-04-02 13:34:12');输出:2015-04-02122.from_unixtime:转化unix时间戳到当 ...

  5. 1、Appium Desktop介绍

    Appium Desktop是一款适用于Mac,Windows和Linux的开源应用程序,它以美观而灵活的用户界面为您提供Appium自动化服务器的强大功能.它是几个Appium相关工具的组合: Ap ...

  6. Flink DataStream API

    Data Sources 源是程序读取输入数据的位置.可以使用 StreamExecutionEnvironment.addSource(sourceFunction) 将源添加到程序.Flink 有 ...

  7. Maven Optional & Exclusions使用区别

    Optional和Exclusions都是用来排除jar包依赖使用的,两者在使用上却是相反. Optional定义后,该依赖只能在本项目中传递,不会传递到引用该项目的父项目中,父项目需要主动引用该依赖 ...

  8. [BOI2009]Radio Transmission 无线传输

    题目描述 给你一个字符串,它是由某个字符串不断自我连接形成的. 但是这个字符串是不确定的,现在只想知道它的最短长度是多少. 输入输出格式 输入格式: 第一行给出字符串的长度,1 < L ≤ 1, ...

  9. 几何问题 poj 1408

    参考博客: 用向量积求线段焦点证明: 首先,我们设 (AD向量 × AC向量) 为 multi(ADC) : 那么 S三角形ADC = multi(ADC)/2 . 由三角形DPD1 与 三角形CPC ...

  10. pytest-mark跳过

    import pytestimport sysenvironment='android' @pytest.mark.skipif(environment=="android",re ...