《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 ...
随机推荐
- shell脚本中:单引号和双引号的区别
单引号和双引号的区别 前面我们还留下一个疑问,定义变量时,变量的值可以由单引号' '包围,也可以由双引号" "包围,它们到底有什么区别呢?不妨以下面的代码为例来说明: #!/bin ...
- ACM-ICPC 训练平台 & 比赛 分析
the file can download in https://pan.baidu.com/s/1HwoLFHGAG-boQbIn9xIhxA occ5 the article is also pu ...
- FFT最新卡常研究
指针优化并没有什么卵用,反而增大了代码的不可读性. 除了本来的循环顺序优化寻址,在预处理单位复数根时,可以连续存储,以增快寻址速度,细节见代码. 代码给出的是FFT,NTT是一样的. #include ...
- javascript html jquery 入门
就开发难易程度来说,现在普遍使用jquery,本人学习jquery html css时间不长,以前写过Flex. CSS+JS+HTML组成HTML开发三驾马车.学习js开发我认为怎么入门十分重要.根 ...
- mysql8以上版本时区问题:The server time zone value乱码XXXX
异常类似: The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone. ...
- C#枚举转化示例大全,数字或字符串转枚举
本文重点举例说明C#枚举的用法,数字转化为枚举.枚举转化为数字及其枚举数值的判断,以下是具体的示例: 先举两个简单的例子,然后再详细的举例说明: 字符串转换成枚举:DayOfWeek week=(Da ...
- Android代号、版本及API级别之间的对应关系
参考链接:Codenames, Tags, and Build Numbers | Android Open Source Project
- EXCEL表格链接SQLSEVER数据库
Sub 数据库连接() Set Cnn = CreateObject("ADODB.Connection") Set rs = CreateObject(" ...
- 【学术篇】SDOI2009 最优图像
又是一道辣鸡卡常数题…. luogu上有些题的时限还是有毒的… 最后也只能靠O2过掉了… 不过给我原题当时的2s我随便过给你看嘛, 哪怕评测姬慢50%都没关系的.. 贴一下codevs的截图… 你看最 ...
- Git 如何使用ssh上传或者同步/下载项目到github
上传本地代码及更新代码到GitHub教程 上传本地代码 第一步:去github上创建自己的Repository,创建页面如下图所示: 红框为新建的仓库的https地址 第二步: echo " ...