1. %% ------------------------------------------------------------------------
  2. %% Output Info about this m-file
  3. fprintf('\n***********************************************************\n');
  4. fprintf(' <DSP using MATLAB> Exameple 8.29 \n\n');
  5.  
  6. time_stamp = datestr(now, 31);
  7. [wkd1, wkd2] = weekday(today, 'long');
  8. fprintf(' Now is %20s, and it is %8s \n\n', time_stamp, wkd2);
  9. %% ------------------------------------------------------------------------
  10.  
  11. % Digital Filter Specifications: Elliptic bandpass
  12. ws = [0.3*pi 0.75*pi]; % digital stopband freq in rad
  13. wp = [0.4*pi 0.6*pi]; % digital passband freq in rad
  14. Rp = 1; % passband ripple in dB
  15. As = 40; % stopband attenuation in dB
  16.  
  17. % Calculation of Elliptic filter parameters:
  18. [N, wn] = ellipord(wp/pi, ws/pi, Rp, As);
  19.  
  20. fprintf('\n ********* Elliptic Filter Order is = %3.0f \n', N)
  21.  
  22. % Digital Elliptic Bandpass Filter Design:
  23. [bhp, ahp] = ellip(N, Rp, As, wn);
  24.  
  25. [C, B, A] = dir2cas(bhp, ahp)
  26.  
  27. % Calculation of Frequency Response:
  28. %[dblp, maglp, phalp, grdlp, wwlp] = freqz_m(blp, alp);
  29. [dbhp, maghp, phahp, grdhp, wwhp] = freqz_m(bhp, ahp);
  30.  
  31. %% -----------------------------------------------------------------
  32. %% Plot
  33. %% -----------------------------------------------------------------
  34.  
  35. figure('NumberTitle', 'off', 'Name', 'Exameple 8.29')
  36. set(gcf,'Color','white');
  37. M = 1; % Omega max
  38.  
  39. subplot(2,2,1); plot(wwhp/pi, maghp); axis([0, M, 0, 1.2]); grid on;
  40. xlabel(' frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
  41. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.6, 0.75, M]);
  42. set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.8913, 1]);
  43.  
  44. subplot(2,2,2); plot(wwhp/pi, dbhp); axis([0, M, -50, 2]); grid on;
  45. xlabel(' frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB');
  46. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.6, 0.75, M]);
  47. set(gca, 'YTickMode', 'manual', 'YTick', [-50, -40, -1, 0]);
  48.  
  49. subplot(2,2,3); plot(wwhp/pi, phahp/pi); axis([0, M, -1.1, 1.1]); grid on;
  50. xlabel('frequency in \pi nuits'); ylabel('radians in \pi units'); title('Phase Response');
  51. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.6, 0.75, M]);
  52. set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]);
  53.  
  54. subplot(2,2,4); plot(wwhp/pi, grdhp); axis([0, M, 0, 40]); grid on;
  55. xlabel('frequency in \pi units'); ylabel('Samples'); title('Group Delay');
  56. set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.6, 0.75, M]);
  57. set(gca, 'YTickMode', 'manual', 'YTick', [0:10:40]);

  运行结果:

注意,设计的滤波器是阶数为10。频率响应如下图,

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

  1. 《DSP using MATLAB》Problem 8.29

    来汉有一月,往日的高温由于最近几个台风沿海登陆影响,今天终于下雨了,凉爽了几个小时. 接着做题. %% ------------------------------------------------ ...

  2. 《DSP using MATLAB》Problem 7.29

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

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

  4. DSP using MATLAB 示例 Example3.19

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

  5. DSP using MATLAB示例Example3.18

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

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

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

  8. DSP using MATLAB 示例Example3.17

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

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

随机推荐

  1. css 固定宽度,自动换行

    max-width: 200px; display: block; word-break: break-all:

  2. java网络编程之图片上传

    输入输出流核心代码 所有的文件传输都是靠流,其中文件复制最具代表性.输入流和输出流,从输入流中读取数据写入到输出流中. InputStream in = 输入源; OutputStream os = ...

  3. 重新学习MySQL数据库4:Mysql索引实现原理

    重新学习Mysql数据库4:Mysql索引实现原理 MySQL索引类型 (https://www.cnblogs.com/luyucheng/p/6289714.html) 一.简介 MySQL目前主 ...

  4. 强连通分量算法-codevs1332

    解决有向图的强连通分量的算法,有两个,一个是tarjan,一个是kosaraju,上午只看了一下kosaraju,不算太难,理解之后写了个模板题. 先说kosaraju算法,算法的主要思路是进行两次d ...

  5. SPOJ 694 && SPOJ 705 (不重复子串个数:后缀数组)

    题意 给定一个字符串,求它的所有不重复子串的个数 思路 一个字符串的子串都必然是它的某个后缀的前缀.对于每一个sa[i]后缀,它的起始位置sa[i],那么它最多能得到该后缀长度个子串(n-sa[i]个 ...

  6. os模块、文件压缩 、匹配文件后缀名:fnmatch glob

    一.os模块 os模块:是python是系统交互的模块 import os # 0平台信息的一些操作 python是夸平台的,所以内部兼容了不同的平台 1. os.name # 操作系统 nt是win ...

  7. linux中的redis缓存服务器

    Linux中的Redis缓存服务器 一.Redis基础部分: 1.redis介绍与安装比mysql快10倍以上 *****************redis适用场合**************** 1 ...

  8. iTabs Tab切换插件

    最近项目中使用到Tab切换,切换的页面不变,内容发生变化,随手写了份简单的插件,附带源码.先看样子: 本人也考虑到是否使用jquery ui tab,但是还是热衷于自己写一份,首先好处之一是易于培训, ...

  9. Django中通过定时任务触发页面静态化的方式

    安装 pip install django-crontab 添加应用 INSTALLED_APPS = [ ... 'django_crontab', # 定时任务 ... ] 设置任务的定时时间 在 ...

  10. 动态加载vs静态加载

    动态加载: 1:灵活,可以在需要的时候用LoadLibrary进行加载,在不需要的时候用FreeLibrary进行卸载,这样可以不必占用内存. 2:可以在没有dll时候发现,而不致程序报错. 3:加载 ...