代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.43 \n\n'); banner();
%% ------------------------------------------------------------------------ % Digital Highpass Filter Specifications:
wphp = 0.4*pi; % digital passband freq in rad
wshp = 0.3*pi; % digital stopband freq in rad
Rp = 1.0; % passband ripple in dB
As = 40; % stopband attenuation in dB Ripple = 10 ^ (-Rp/20) % passband ripple in absolute
Attn = 10 ^ (-As/20) % stopband attenuation in absolute fprintf('\n*******Digital Highpass, Coefficients of DIRECT-form***********\n');
%[bhp, ahp] = butthpf(wphp, wshp, Rp, As)
%[bhp, ahp] = cheb1hpf(wphp, wshp, Rp, As)
%[bhp, ahp] = cheb2hpf(wphp, wshp, Rp, As)
[bhp, ahp] = eliphpf(wphp, wshp, Rp, As);
[C, B, A] = dir2cas(bhp, ahp) % Calculation of Frequency Response:
%[dblp, maglp, phalp, grdlp, wwlp] = freqz_m(blp, alp);
[dbhp, maghp, phahp, grdhp, wwhp] = freqz_m(bhp, ahp); % ---------------------------------------------------------------
% find Actual Passband Ripple and Min Stopband attenuation
% ---------------------------------------------------------------
delta_w = 2*pi/1000;
Rp_hp = -(min(dbhp(ceil(wphp/delta_w+1):1:501))); % Actual Passband Ripple fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp_hp); As_hp = -round(max(dbhp(1:1:ceil(wshp/delta_w)+1))); % Min Stopband attenuation
fprintf('\nMin Stopband attenuation is %.4f dB.\n\n', As_hp); %% -----------------------------------------------------------------
%% Plot
%% overall analog filter over the [0, 5KHz] inteval
%% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Problem 8.43 Elliptic Highpass by eliphpf function')
set(gcf,'Color','white');
M = 1; % Omega max
Fs = 10; % sampling rate of 10 KHz subplot(2,2,1); plot(wwhp*Fs/(2*pi), maghp); grid on;%axis([0, M, 0, 1.2]);
%xlabel('Digital frequency in \pi units');
xlabel('analog frequency in KHz units');
ylabel('|H|'); title('Highpass Filter Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, M]*Fs/2);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.8913, 1]); subplot(2,2,2); plot(wwhp*Fs/(2*pi), dbhp); grid on;%axis([0, M, -100, 2]);
%xlabel('Digital frequency in \pi units');
xlabel('analog frequency in KHz units');
ylabel('Decibels'); title('Highpass Filter Magnitude in dB');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, M]*Fs/2);
set(gca, 'YTickMode', 'manual', 'YTick', [-70, -40, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['70'; '40';'1 ';' 0']); subplot(2,2,3); plot(wwhp*Fs/(2*pi), phahp/pi); grid on; %axis([0, M, -1.1, 1.1]);
%xlabel('Digital frequency in \pi nuits');
xlabel('analog frequency in KHz units');
ylabel('radians in \pi units'); title('Highpass Filter Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, M]*Fs/2);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]); subplot(2,2,4); plot(wwhp*Fs/(2*pi), grdhp); grid on; %axis([0, M, 0, 25]);
%xlabel('Digital frequency in \pi units');
xlabel('analog frequency in KHz units');
ylabel('Samples'); title('Highpass Filter Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, M]*Fs/2);
set(gca, 'YTickMode', 'manual', 'YTick', [0:10:25]); % ----------------------------------------------------------
% Part 2 digital prototype lowpass filter
% ----------------------------------------------------------
% Digital lowpass Filter Specifications:
[wpLP, wsLP, alpha] = hp2lpfre(wphp, wshp); % Calculation of Elliptic lp filter parameters:
[N, wn] = ellipord(wpLP/pi, wsLP/pi, Rp, As);
fprintf('\n********** Elliptic Filter Order = %3.0f \n', N) % Digital Elliptic lowpass Filter Design:
[blp, alp] = ellip(N, Rp, As, wn, 'low'); [C, B, A] = dir2cas(blp, alp) % Calculation of Frequency Response:
[dblp, maglp, phalp, grdlp, wwlp] = freqz_m(blp, alp); % ---------------------------------------------------------------
% find Actual Passband Ripple and Min Stopband attenuation
% ---------------------------------------------------------------
delta_w = 2*pi/1000;
Rp_lp = -(min(dblp(1:1:ceil(wpLP/delta_w+1)+1))); % Actual Passband Ripple fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp_lp); As_lp = -round(max(dblp(ceil(wsLP/delta_w)+1):1:501)); % Min Stopband attenuation
fprintf('\nMin Stopband attenuation is %.4f dB.\n\n', As_lp); %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Problem 8.43 Elliptic Prototype Lowpass by ellip function')
set(gcf,'Color','white');
M = 1; % Omega max subplot(2,2,1); plot(wwlp/pi, maglp); axis([0, M, 0, 1.2]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('|H|');
title('lowpass Filter Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, wpLP, wsLP, pi]/pi);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.8913, 1]); subplot(2,2,2); plot(wwlp/pi, dblp); axis([0, M, -100, 2]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Decibels');
title('lowpass Filter Magnitude in dB');
set(gca, 'XTickMode', 'manual', 'XTick', [0, wpLP, wsLP, pi]/pi);
set(gca, 'YTickMode', 'manual', 'YTick', [-70, -40, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['70'; '40';'1 ';' 0']); subplot(2,2,3); plot(wwlp/pi, phalp/pi); axis([0, M, -1.1, 1.1]); grid on;
xlabel('Digital frequency in \pi nuits'); ylabel('radians in \pi units');
title('lowpass Filter Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, wpLP, wsLP, pi]/pi);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]); subplot(2,2,4); plot(wwlp/pi, grdlp); axis([0, M, 0, 25]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Samples');
title('lowpass Filter Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, wpLP, wsLP, pi]/pi);
set(gca, 'YTickMode', 'manual', 'YTick', [0:5:25]); % -----------------------------------------------------
% Part 3 ellip function
% -----------------------------------------------------
% Calculation of Elliptic hp filter parameters:
[N, wn] = ellipord(wphp/pi, wshp/pi, Rp, As);
fprintf('\n********** Elliptic Digital Highpass Filter Order = %3.0f \n', N) % Digital Elliptic Highpass Filter Design:
[bhp, ahp] = ellip(N, Rp, As, wn, 'high'); [C, B, A] = dir2cas(bhp, ahp) % Calculation of Frequency Response:
%[dblp, maglp, phalp, grdlp, wwlp] = freqz_m(blp, alp);
[dbhp, maghp, phahp, grdhp, wwhp] = freqz_m(bhp, ahp); % ---------------------------------------------------------------
% find Actual Passband Ripple and Min Stopband attenuation
% ---------------------------------------------------------------
delta_w = 2*pi/1000;
Rp_hp = -(min(dbhp(ceil(wphp/delta_w+1):1:501))); % Actual Passband Ripple fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp_hp); As_hp = -round(max(dbhp(1:1:ceil(wshp/delta_w)+1))); % Min Stopband attenuation
fprintf('\nMin Stopband attenuation is %.4f dB.\n\n', As_hp); %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Problem 8.43 Elliptic Highpass by ellip function')
set(gcf,'Color','white');
M = 1; % Omega max subplot(2,2,1); plot(wwhp/pi, maghp); axis([0, M, 0, 1.2]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('|H|'); title('Highpass Filter Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.8913, 1]); subplot(2,2,2); plot(wwhp/pi, dbhp); axis([0, M, -100, 2]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Decibels'); title('Highpass Filter Magnitude in dB');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-70, -40, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['70'; '40';'1 ';' 0']); subplot(2,2,3); plot(wwhp/pi, phahp/pi); axis([0, M, -1.1, 1.1]); grid on;
xlabel('Digital frequency in \pi nuits'); ylabel('radians in \pi units'); title('Highpass Filter Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]); subplot(2,2,4); plot(wwhp/pi, grdhp); axis([0, M, 0, 25]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Samples'); title('Highpass Filter Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0:5:25]);

  运行结果:

通带、阻带设计指标,绝对值单位

Elliptic型数字高通,滤波器系统函数串联形式的系数如下,阶数是5阶

采用eliphpf函数,设计的Elliptic型数字高通,幅度谱、相位谱和群延迟响应

第2小题,要画出数字低通原型的幅度谱。

Elliptic型数字低通滤波器,系统函数串联形式系数如下

采用ellip函数(MATLAB工具箱函数),设计的Elliptic型数字高通滤波器,系统函数串联形式系数如下,

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

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

  1. 《DSP using MATLAB》Problem 7.16

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

  2. 《DSP using MATLAB》Problem 7.38

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

  3. 《DSP using MATLAB》Problem 7.27

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

  4. 《DSP using MATLAB》Problem 7.26

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

  5. 《DSP using MATLAB》Problem 7.25

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

  6. 《DSP using MATLAB》Problem 7.24

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

  7. 《DSP using MATLAB》Problem 7.23

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

  8. 《DSP using MATLAB》Problem 7.15

    用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  9. 《DSP using MATLAB》Problem 7.14

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

随机推荐

  1. aspcms 这个靶场。。。

    这个网站源码是我打 webug 里收集的靶场,但是由于我自己水平菜的不行,没搭建成功 = =!然后,我也就懒的搞,就给我一朋友,在他的公网服务器上搭上这个站,好让我玩玩.由于上次我朋友靶场发生挂黑页的 ...

  2. STM32嵌入式开发学习笔记(四):使用滴答计时器实现精准计时

    前面我们讲过,因为在STM32上没有系统时间的接口,因此无法调用sleep函数,在本文中,笔者将利用滴答计时器实现精准延时. 查阅技术手册,滴答计时器依赖于一个SysTick_Type类型寄存器,定义 ...

  3. winform界面设计

    http://www.cnblogs.com/wuhuacong/  这位大师给了我指导方向 http://officeribbon.codeplex.com 提供了ribbon界面的控件 动态web ...

  4. C++——Struct 和 Union区别

    1.在存储多个成员信息时,编译器会自动给struct第个成员分配存储空间,struct 可以存储多个成员信息,而Union每个成员会用同一个存储空间,只能存储最后一个成员的信息. 2.都是由多个不同的 ...

  5. JDK在Win10与Ubuntu下的安装与配置

        本文首发于cartoon的博客     转载请注明出处:https://cartoonyu.github.io/cartoon-blog     近段时间把自己电脑(win).虚拟机(Ubun ...

  6. 47-Ubuntu-系统信息-2-df和du查看磁盘和目录空间占用

    序号 命令 作用 01 df -h disk free 显示磁盘剩余空间;-h以人性化的方式显示文件大小 02 du -h [目录名] disk usage 显示目录下的文件大小 注:显示磁盘信息的时 ...

  7. Oracle中NEXTVAL 和 CURRVAL的使用

    能够通过在 SQL 语句中使用 NEXTVAL 或 CURRVAL 运算符来訪问序列的值.必须用以 sequence.NEXTVAL 或sequence.CURRVAL 格式驻留在同一个数据库中的序列 ...

  8. 集成 Swagger2 构建强大的 RESTful API 文档

    微信公众号:一个优秀的废人如有问题或建议,请后台留言,我会尽力解决你的问题. 前言 快过年了,不知道你们啥时候放年假,忙不忙.反正我是挺闲的,所以有时间写 blog.今天给你们带来 SpringBoo ...

  9. 一键抓取Android的Locat Log

    很多小伙伴在做App测试时,一遇到Cash,开发同学最常说的一句话,就是抓下Locat日志,很多小伙伴一听到这个抓取日志就会觉得有点烦. ​主要有2点: ​    ​    ​1.是这个bug可能不好 ...

  10. yum处理损坏的包依赖关系

    有时在安装多个软件包时,某个包的软件依赖关系可能会被另外一个包的安装覆盖掉.这叫做损坏的包依赖关系(broken dependency). 如果系统出现问题,可以先尝试: yum clean all ...