《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 ...
随机推荐
- 莫比乌斯反演+二维前缀和——hdu4746二刷
第二次做这题,求前缀和的时候还是卡住了 fg函数的反演是可以直接用莫比乌斯基本代换式来代换的 #include<bits/stdc++.h> using namespace std; #d ...
- cdh maven仓库地址
常用的maven仓库地址: 中央库:http://repo.maven.apache.org/maven2/ cdh库:https://repository.cloudera.com/artifact ...
- C/C++ Muti-Thread多线程编程学习(之)线程Thread | 创建、运行、结束
文章目录 前言 线程 Thread 创建线程 CreateThread _beginthread _beginthreadex pthread_create 线程运行 结束线程 前言 多线程(Mu ...
- NX二次开发-UFUN创建倒角UF_MODL_create_chamfer
NX9+VS2012 #include <uf.h> #include <uf_modl.h> UF_initialize(); //创建块 UF_FEATURE_SIGN S ...
- fedora23上安装和运行MySQL server (MySQL 已经被MariaDB取代)
[root@localhost kemin]# dnf install mysql-server Fedora 23 - x86_64 - Updates ...
- Windows内存管理(2)--Lookaside结构 和 运行时函数
1. Lookaside结构 频繁的申请和回收内存,会导致在内存上产生大量的内存"空洞",从而导致最终无法申请内存.DDK为程序员提供了Lookaside结构来解决这个问 ...
- DXP 快捷键
EC 复制 EY array paste TU: update
- UVA-10200-Prime Time-判断素数个数(打表预处理)+精度控制
题意: 给出a.b区间,判断区间内素数所占百分比 思路: 注意提前打表和控制精度1e-8的范围足够用了 细节: 精度的处理 判断素数的方法(且返回值为bool) 数据类型的强制转换 保存素数个数 提前 ...
- PAT_A1079#Total Sales of Supply Chain
Source: PAT A1079 Total Sales of Supply Chain (25 分) Description: A supply chain is a network of ret ...
- NYOJ - 35 表达式求值 分类: NYOJ 2015-03-18 10:33 31人阅读 评论(0) 收藏
#include<iostream> #include<string> #include<stack> #include<cstdio> using n ...