代码:

function [wpLP, wsLP, alpha] = bp2lpfre(wpbp, wsbp)
% Band-edge frequency conversion from bandpass to lowpass digital filter
% -------------------------------------------------------------------------
% [wpLP, wsLP, alpha] = bp2lpfre(wpbp, wsbp)
% wpLP = passband edge for the lowpass digital prototype
% wsLP = stopband edge for the lowpass digital prototype
% alpha = lowpass to bandpass transformation parameter
% wpbp = passband edge frequency array [wp_lower, wp_upper] for the bandpass
% wshp = stopband edge frequency array [ws_lower, ws_upper] for the bandpass
%
% % Determine the digital lowpass cutoff frequencies:
wpLP = 0.2*pi;
K = cot((wpbp(2)-wpbp(1))/2)*tan(wpLP/2);
beta = cos((wpbp(2)+wpbp(1))/2)/cos((wpbp(2)-wpbp(1))/2);
alpha1 = -2*beta*K/(K+1);
alpha2 = (K-1)/(K+1); alpha = [alpha1, alpha2]; wsLP = -angle(-(exp(-2*j*wsbp(2))+alpha1*exp(-j*wsbp(2))+alpha2)/(alpha2*exp(-2*j*wsbp(2))+alpha1*exp(-j*wsbp(2))+1))
%wsLP = angle(-(exp(-2*j*wsbp(1))+alpha1*exp(-j*wsbp(1))+alpha2)/(alpha2*exp(-2*j*wsbp(1))+alpha1*exp(-j*wsbp(1))+1))

  主程序代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.38.3 \n\n'); banner();
%% ------------------------------------------------------------------------ % Digital Filter Specifications: Chebyshev-2 bandpass
wsbp = [0.30*pi 0.60*pi]; % digital stopband freq in rad
wpbp = [0.40*pi 0.50*pi]; % digital passband freq in rad
Rp = 0.50; % passband ripple in dB
As = 50; % stopband attenuation in dB Ripple = 10 ^ (-Rp/20) % passband ripple in absolute
Attn = 10 ^ (-As/20) % stopband attenuation in absolute fprintf('\n*******Digital bandpass, Coefficients of DIRECT-form***********\n');
[bbp, abp] = cheb2bpf(wpbp, wsbp, Rp, As);
[C, B, A] = dir2cas(bbp, abp) % Calculation of Frequency Response:
[dbbp, magbp, phabp, grdbp, wwbp] = freqz_m(bbp, abp); % ---------------------------------------------------------------
% find Actual Passband Ripple and Min Stopband attenuation
% ---------------------------------------------------------------
delta_w = 2*pi/1000;
Rp_bp = -(min(dbbp(ceil(wpbp(1)/delta_w+1):1:ceil(wpbp(2)/delta_w+1)))); % Actual Passband Ripple fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp_bp); As_bp = -round(max(dbbp(1:1:ceil(wsbp(1)/delta_w)+1))); % Min Stopband attenuation
fprintf('\nMin Stopband attenuation is %.4f dB.\n\n', As_bp); %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Problem 8.38.3 Chebyshev-2 bp by cheb2bpf function')
set(gcf,'Color','white');
M = 1; % Omega max subplot(2,2,1); plot(wwbp/pi, magbp); 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.3, 0.4, 0.5, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.9441, 1]); subplot(2,2,2); plot(wwbp/pi, dbbp); axis([0, M, -100, 2]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.5, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-80, -50, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['80'; '50';'1 ';' 0']); subplot(2,2,3); plot(wwbp/pi, phabp/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.3, 0.4, 0.5, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]); subplot(2,2,4); plot(wwbp/pi, grdbp); axis([0, M, 0, 80]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Samples'); title('Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.5, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0:20:80]); figure('NumberTitle', 'off', 'Name', 'Problem 8.38.3 Pole-Zero Plot')
set(gcf,'Color','white');
zplane(bbp, abp);
title(sprintf('Pole-Zero Plot'));
%pzplotz(b,a); % -----------------------------------------------------
% method 2 cheby2 function
% ----------------------------------------------------- % Calculation of Chebyshev-2 filter parameters:
[N, wn] = cheb2ord(wpbp/pi, wsbp/pi, Rp, As); fprintf('\n ********* Chebyshev-2 Digital Bandpass Filter Order is = %3.0f \n', 2*N) % Digital Chebyshev-2 Bandpass Filter Design:
[bbp, abp] = cheby2(N, As, wn); [C, B, A] = dir2cas(bbp, abp) % Calculation of Frequency Response:
[dbbp, magbp, phabp, grdbp, wwbp] = freqz_m(bbp, abp); % ---------------------------------------------------------------
% find Actual Passband Ripple and Min Stopband attenuation
% ---------------------------------------------------------------
delta_w = 2*pi/1000;
Rp_bp = -(min(dbbp(ceil(wpbp(1)/delta_w+1):1:ceil(wpbp(2)/delta_w+1)))); % Actual Passband Ripple fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp_bp); As_bp = -round(max(dbbp(1:1:ceil(wsbp(1)/delta_w)+1))); % Min Stopband attenuation
fprintf('\nMin Stopband attenuation is %.4f dB.\n\n', As_bp); %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Problem 8.38.3 Chebyshev-2 bp by cheby2 function')
set(gcf,'Color','white');
M = 1; % Omega max subplot(2,2,1); plot(wwbp/pi, magbp); 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.3, 0.4, 0.5, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.9441, 1]); subplot(2,2,2); plot(wwbp/pi, dbbp); axis([0, M, -100, 2]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.5, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-80, -50, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['80'; '50';'1 ';' 0']); subplot(2,2,3); plot(wwbp/pi, phabp/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.3, 0.4, 0.5, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]); subplot(2,2,4); plot(wwbp/pi, grdbp); axis([0, M, 0, 40]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Samples'); title('Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 0.5, 0.6, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0:10:40]);

  运行结果:

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

采用cheb2bpf子函数,得到Chebyshev-2型数字带通滤波器,其系统函数串联形式的系数如下

cheb2bpf函数得数字带通滤波器,幅度谱、相位谱和群延迟响应

系统函数零极点图

采用cheby2函数(MATLAB工具箱函数)得到Chebyshev-2型数字带通滤波器,其系统函数串联形式的系数如下,

上图中的系数和cheb2bpf函数得到的系数相比,略有不同。

cheby2函数(MATLAB工具箱函数),得到的Chebyshev-2型数字带通滤波器,其幅度谱、相位谱和群延迟响应如下图

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

  1. 《DSP using MATLAB》Problem 5.38

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

  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.16

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

  9. 《DSP using MATLAB》Problem 7.15

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

随机推荐

  1. leetcode-126-单词接龙

    题目描述: class Solution: def findLadders(self, beginWord: str, endWord: str, wordList: list) -> list ...

  2. mongodb常用基本命令

    一.数据库常用命令 1.help查看命令提示 help db.help() db.test.help() db.test.find().help() 2.创建.切换数据库 use movies 3.查 ...

  3. Java高新技术第三篇:注解的使用

    我们知道注解是在JDK1.5引入的,可能有的人没有用过注解,所以感觉注解这个东西没有什么用,但是深入了解注解,对以后学习框架有所帮助的,后面提到的JavaWeb的框架中很多都是基于注解的技术, 其实注 ...

  4. C语言-实例3个数由小到大排序

    VS2012 //C语言实例 3个数由小到大排序 #include <stdio.h> void main() { int a, b, c, t; printf("Please ...

  5. Go的异常处理 defer, panic, recover

    Go语言追求简洁优雅,所以,Go语言不支持传统的 try…catch…finally 这种异常,因为Go语言的设计者们认为,将异常与控制结构混在一起会很容易使得代码变得混乱.因为开发者很容易滥用异常, ...

  6. CSS:CSS 实例

    ylbtech-CSS:CSS 实例 1.返回顶部 1. CSS 实例 CSS背景 设置页面的背景颜色 设置不同元素的背景颜色 设置一个图像作为页面的背景 错误的背景图片 如何在水平方向重复背景图像 ...

  7. ionic-Javascript:ionic 上拉菜单(ActionSheet)

    ylbtech-ionic-Javascript:ionic 上拉菜单(ActionSheet) 1.返回顶部 1. ionic 上拉菜单(ActionSheet) 上拉菜单(ActionSheet) ...

  8. (转)Pycharm用鼠标滚轮控制字体大小

    转自: Pycharm用鼠标滚轮控制字体大小 - 暗黒骑士 - 博客园 https://www.cnblogs.com/fyknight/p/6937482.html ---------------- ...

  9. 2019 牛客多校第二场 H Second Large Rectangle

    题目链接:https://ac.nowcoder.com/acm/contest/882/H 题目大意 给定一个 n * m 的 01 矩阵,求其中第二大的子矩阵,子矩阵元素必须全部为 1.输出其大小 ...

  10. scrt 关闭退格键声音

    options-> session Options -> Terminal -> audio bell (删除勾选) 这样就可以在secureCRT 在出错时不‘滴滴’的响了.