《DSP using MATLAB》Problem 8.35

代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.35 \n\n'); banner();
%% ------------------------------------------------------------------------ % Digital Highpass Filter Specifications:
wphp = 0.6*pi; % digital passband freq in rad
wshp = 0.4*pi; % digital stopband freq in rad
Rp = 0.5; % passband ripple in dB
As = 60; % 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
%% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Problem 8.35 Chebyshev-1 Highpass by dhpfd_bl 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.4, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.9441, 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.4, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-70, -61, -60, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['70'; '61'; '60';'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.4, 0.6, 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.4, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0:5:25]); % -----------------------------------------------------
% method 2
% -----------------------------------------------------
% Digital lowpass Filter Specifications:
[wpLP, wsLP, alpha] = hp2lpfre(wphp, wshp); prompt = 'Please input the type of digital lp filter: \n\n butter or cheby1 or cheby2 or ellip [butter]: ';
type = input(prompt , 's'); [bhp, ahp] = dhpfd_bl(type, wphp, wshp, Rp, As) [C, B, A] = dir2cas(bhp, ahp) % -----------------------------------------------------
% method 3 cheby1 function
% -----------------------------------------------------
% Calculation of Chebyshev-1 hp filter parameters:
[N, wn] = cheb1ord(wphp/pi, wshp/pi, Rp, As); % Digital Chebyshev-1 Highpass Filter Design:
[bhp, ahp] = cheby1(N, Rp, 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.35 Chebyshev-1 Highpass by cheby1 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.4, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.9441, 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.4, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-70, -61, -60, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['70'; '61'; '60';'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.4, 0.6, 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.4, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0:5:25]);
运行结果:
采用dhpfd_bl函数,获得Chebyshev-1型数字高通滤波器,系统函数直接形式的系数




最小阻带衰减达到61dB,满足设计要求。

采用dhpfd_bl函数和cheby1函数(MATLAB自带)设计数字高通滤波器,幅度谱、相位谱和群延迟对比,相差不大。


《DSP using MATLAB》Problem 8.35的更多相关文章
- 《DSP using MATLAB》Problem 5.35
余弦序列的谱,原始频率w0会泄露到其它频率处. 从其它书中找到的证明过程: 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.35
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.23
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
- 《DSP using MATLAB》Problem 7.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.13
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.11
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.10
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.9
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
随机推荐
- c 语言函数分析
第一个参数为指向线程标识符的指针. 第二个参数用来设置线程属性. 第三个参数是线程运行函数的起始地址. 最后一个参数是运行函数的参数. result = pthread_create(&tid ...
- php Excel导出功能
/** * * execl数据导出 */ function exportOrderExcel2($title, $cellName, $data) { //引入核心文件 vendor("PH ...
- FontFamily 和Font 的区别
GDI+ 将字样相同但字形不同的字体分组为字体系列.例如,下面是同一个字样(Arial),不同的字形 : ----------------------------------------------- ...
- 51nod 1627 瞬间移动(组合数学)
传送门 解题思路 因为每次横纵坐标至少\(+1\),所以可以枚举走的步数,枚举走的步数\(i\)后剩下的就是把\(n-1\)与\(m-1\)划分成\(i\)个有序正整数相加,所以用隔板法,\(ans= ...
- IIS反向代理解决Web前端跨域
1.1 IIS7反向代理解决跨域问题IIS的版本必须是IIS7及其以上,否则没有反向代理功能:按照以下步骤来配置IIS,以实现反向代理: 1.2 配置步骤1. 下载安装ARR(Application ...
- Codeforces786B
传送门 n个节点且固定起点最短路,三种加边方法 1.u->v, 边权为w:2. u->[l, r], 边权为w:3. [l, r]->u, 边权为w AC_Code #include ...
- IDEA web 开发环境搭建
最近由eclipse 换 IDEA ,记录下开发环境的搭建过程. 1 配置idea vim 既可以使用IDEA方便的代码提示和调试功能,又可以方便使用vim编辑文件,安装完成后显示为vim Emula ...
- Jsoup 学习笔记
这里写自定义目录标题 Jsoup 学习笔记 解析 HTML 的字符串解析 URL 解析 本地文件解析 解析数据 DOM 解析 使用选择器解析 选择器概述 选择器组合用法 过滤用法 修改数据 HTML ...
- 【LGP5439】【XR-2】永恒
题目 是个傻题 显然枚举每一条路径经过了多少次,如果\(u,v\)在树上不是祖先关系的话经过\((u,v)\)这条路径的路径条数就是\(sum_u\times sum_v\) 于是我们子树大小映射到\ ...
- Nginx软件模块说明
Nginx软件模块说明 Nginx常用模块 注:以下只是列举Nginx常用模块,需要详细了解更多模块可以登录Nginx官方网站查看 功能模块 模块说明 ngx_http_core_module 包含一 ...