《DSP using MATLAB》Problem 8.39

代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.39.2 \n\n'); banner();
%% ------------------------------------------------------------------------ % Digital Filter Specifications: Chebyshev-1 bandstop
ws = [0.35*pi 0.65*pi]; % digital stopband freq in rad
wp = [0.25*pi 0.75*pi]; % digital passband freq in rad delta1 = 0.05; % passband tolerance, absolute specs
delta2 = 0.01; % stopband tolerance, absolute specs Rp = -20 * log10( (1-delta1)/(1+delta1)) % passband ripple in dB
As = -20 * log10( delta2 / (1+delta1)) % stopband attenuation in dB Ripple = 10 ^ (-Rp/20) % passband ripple in absolute
Attn = 10 ^ (-As/20) % stopband attenuation in absolute % Calculation of Chebyshev-1 filter parameters:
[N, wn] = cheb1ord(wp/pi, ws/pi, Rp, As); fprintf('\n ********* Chebyshev-1 Digital Bandstop Filter Order is = %3.0f \n', 2*N) % Digital Chebyshev-1 bandstop Filter Design:
[bbs, abs] = cheby1(N, Rp, wn, 'stop'); [C, B, A] = dir2cas(bbs, abs) % Calculation of Frequency Response:
[dbbs, magbs, phabs, grdbs, wwbs] = freqz_m(bbs, abs); % ---------------------------------------------------------------
% find Actual Passband Ripple and Min Stopband attenuation
% ---------------------------------------------------------------
delta_w = 2*pi/1000;
Rp_bs = -(min(dbbs(1:1:ceil(wp(1)/delta_w+1)))); % Actual Passband Ripple fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp_bs); As_bs = -round(max(dbbs(ceil(ws(1)/delta_w)+1:1:ceil(ws(2)/delta_w)+1))); % Min Stopband attenuation
fprintf('\nMin Stopband attenuation is %.4f dB.\n\n', As_bs); %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Problem 8.39.2 Chebyshev-1 bs by cheby1 function')
set(gcf,'Color','white');
M = 1; % Omega max subplot(2,2,1); plot(wwbs/pi, magbs); axis([0, M, 0, 1.2]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.25, 0.35, 0.65, 0.75, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.01, 0.9048, 1]); subplot(2,2,2); plot(wwbs/pi, dbbs); axis([0, M, -120, 2]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.25, 0.35, 0.65, 0.75, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-80, -40, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['80'; '40';'1 ';' 0']); subplot(2,2,3); plot(wwbs/pi, phabs/pi); axis([0, M, -1.1, 1.1]); grid on;
xlabel('Digital frequency in \pi nuits'); ylabel('radians in \pi units'); title('Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.25, 0.35, 0.65, 0.75, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]); subplot(2,2,4); plot(wwbs/pi, grdbs); axis([0, M, 0, 50]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Samples'); title('Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.25, 0.35, 0.65, 0.75, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0:20:50]);
运行结果:
通带、阻带衰减指标,dB单位和绝对值单位,

使用cheby1函数(MATLAB工具箱函数)得到Chebyshev-1型数字带阻滤波器,系统函数串联形式的系数

最小阻带衰减为44dB,满足40.4238dB的设计要求。滤波器的幅度谱、相位谱和群延迟响应如下

类似的,使用butter、cheby2和ellip函数(都是MATLAB工具箱函数)也可以设计带阻滤波器,这里不放图了。
《DSP using MATLAB》Problem 8.39的更多相关文章
- 《DSP using MATLAB》Problem 5.19
代码: function [X1k, X2k] = real2dft(x1, x2, N) %% --------------------------------------------------- ...
- 《DSP using MATLAB》Problem 8.40
代码: function [wpLP, wsLP, alpha] = bs2lpfre(wpbs, wsbs) % Band-edge frequency conversion from bandst ...
- 《DSP using MATLAB》Problem 7.36
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.28
又是一年五一节,朋友圈都是晒名山大川的,晒脑袋的,我这没钱的待在家里上网转转吧 频率采样法设计带通滤波器,过渡带中有一个样点 代码: %% ++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.25
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.24
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.23
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
随机推荐
- Thinkphp 3.2 去掉index.php
1.httpd.conf中去掉LoadModule rewrite_module modules/mod_rewrite.so 前面的#号 2.httpd.conf 中 AllowOverride ...
- Exception一自定义异常
异常体系的根类是:Throwable Throwable: Error: 重大的问题,我们处理不了.也不需要编写代码处理.比如说内存溢出. Exception: 一般性的错误,是需要我们对编写 ...
- 【Bootstrap】 框架 栅格布局系统设计原理
前提条件(Bootstrap 自带) 首先使用这个布局之前要定义一下代码: 这行代码如果不懂,可以搜索一下,总之大致意思就是,被定义的元素的内边距和边框不再会增加它的宽度,不加入的话排版会有问题. 不 ...
- 干货满满!解密阿里云RPA (机器人流程自动化)的产品架构和商业化发展
阿里云RPA,作为阿里云自研8年的技术,在资本的热捧下,逐渐从幕后来到台前,成为企业服务市场的黑马.本文将从产品上全面剖析,阿里云RPA这款产品的现阶段情况,同时简单谈谈阿里云RPA的商业化进展. 阿 ...
- [JZOJ 5819] 大逃杀
题意:求一个树上背包~~ 先贴代码存一下,好像打挂了. #include <bits/stdc++.h> using namespace std; const int maxn = 400 ...
- Unity3D中的线程与协程
线程 Unity3D是以生命周期主线程循环进行游戏开发. Unity3D中的子线程无法运行Unity SDK(开发者工具包,软件包.软件框架)跟API(应用程序编程接口,函数库). 限制原因:大多数游 ...
- Python 爬虫-抓取小说《盗墓笔记-怒海潜沙》
最近想看盗墓笔记,看了一下网页代码,竟然不是js防爬虫,那就用简单的代码爬下了一节: """ 爬取盗墓笔记小说-七星鲁王宫 """ from ...
- UVA 10382 Watering Grass 贪心+区间覆盖问题
n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each spri ...
- java执行spark查询hbase的jar包出现错误提示:ob aborted due to stage failure: Master removed our application: FAILED
执行java调用scala 打包后的jar时候出现异常 /14 23:57:08 WARN TaskSchedulerImpl: Initial job has not accepted any re ...
- Number Sequence /// oj21456
题目大意: 有一组规律数 the first 80 digits of the sequence are as follows: 1 12 123 1234 12345 123456 1234567 ...