《DSP using MATLAB》Problem 8.11


代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.11 \n\n');
banner();
%% ------------------------------------------------------------------------ %d = 0.10
%d = 0.05
d = 0.01 a1 = (2-d)/(1+d);
a2 = (2-d)*(1-d)/((2+d)*(1+d)); % digital IIR 2nd-order allpass filter
b = [a2 a1 1]
a = [1 a1 a2] figure('NumberTitle', 'off', 'Name', 'Problem 8.11 Pole-Zero Plot')
set(gcf,'Color','white');
zplane(b,a);
title(sprintf('Pole-Zero Plot, d=%.2f',d));
%pzplotz(b,a); [db, mag, pha, grd, w] = freqz_m(b, a); % ---------------------------------------------------------------------
% Choose the gain parameter of the filter, maximum gain is equal to 1
% ---------------------------------------------------------------------
gain1=max(mag) % with poles
K = 1
[db, mag, pha, grd, w] = freqz_m(K*b, a); figure('NumberTitle', 'off', 'Name', 'Problem 8.11 IIR allpass filter')
set(gcf,'Color','white'); subplot(2,2,1); plot(w/pi, db); grid on; axis([0 2 -60 10]);
set(gca,'YTickMode','manual','YTick',[-60,-30,0])
set(gca,'YTickLabelMode','manual','YTickLabel',['60';'30';' 0']);
set(gca,'XTickMode','manual','XTick',[0,0.25,0.5,1,1.5,1.75,2]);
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response in dB'); subplot(2,2,3); plot(w/pi, mag); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Absolute'); title('Magnitude Response in absolute');
set(gca,'XTickMode','manual','XTick',[0,0.25,0.5,1,1.5,1.75,2]);
set(gca,'YTickMode','manual','YTick',[0,1.0]); subplot(2,2,2); plot(w/pi, pha); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Phase Response in Radians'); subplot(2,2,4); plot(w/pi, grd*pi/180); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Group Delay');
set(gca,'XTickMode','manual','XTick',[0,0.25,0.5,1,1.5,1.75,2]);
%set(gca,'YTickMode','manual','YTick',[0,1.0]); figure('NumberTitle', 'off', 'Name', 'Problem 8.11 IIR allpass filter')
set(gcf,'Color','white');
plot(w/pi, -pha/w); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Phase Delay in samples'); % Impulse Response
fprintf('\n----------------------------------');
fprintf('\nPartial fraction expansion method: \n');
[R, p, c] = residuez(K*b,a)
MR = (abs(R))' % Residue Magnitude
AR = (angle(R))'/pi % Residue angles in pi units
Mp = (abs(p))' % pole Magnitude
Ap = (angle(p))'/pi % pole angles in pi units
[delta, n] = impseq(0,0,20);
h_chk = filter(K*b,a,delta); % check sequences % ------------------------------------------------------------------------------------------------
% gain parameter K
% ------------------------------------------------------------------------------------------------
%h = 0.2202 * ((-0.9385) .^ n) + (-0.8308) * ((-0.7887) .^ n) + 1.3509 * delta; %d=0.1
%h = 0.1099 * ((-0.9688) .^ n) + (-0.4112) * ((-0.8884) .^ n) + 1.1619 * delta; %d=0.05
h = 0.0220 * ((-0.9937) .^ n) + (-0.0820) * ((-0.9766) .^ n) + 1.0305 * delta; %d=0.01
% ------------------------------------------------------------------------------------------------ figure('NumberTitle', 'off', 'Name', 'Problem 8.11 IIR allpass filter, h(n) by filter and Inv-Z ')
set(gcf,'Color','white'); subplot(2,1,1); stem(n, h_chk); grid on; %axis([0 2 -60 10]);
xlabel('n'); ylabel('h\_chk'); title('Impulse Response sequences by filter'); subplot(2,1,2); stem(n, h); grid on; %axis([0 1 -100 10]);
xlabel('n'); ylabel('h'); title('Impulse Response sequences by Inv-Z'); [db, mag, pha, grd, w] = freqz_m(h, [1]); figure('NumberTitle', 'off', 'Name', 'Problem 8.11 IIR filter, h(n) by Inv-Z ')
set(gcf,'Color','white'); subplot(2,2,1); plot(w/pi, db); grid on; axis([0 2 -60 10]);
set(gca,'YTickMode','manual','YTick',[-60,-30,0])
set(gca,'YTickLabelMode','manual','YTickLabel',['60';'30';' 0']);
set(gca,'XTickMode','manual','XTick',[0,0.25,1,1.75,2]);
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response in dB'); subplot(2,2,3); plot(w/pi, mag); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Absolute'); title('Magnitude Response in absolute');
set(gca,'XTickMode','manual','XTick',[0,0.25,1,1.75,2]);
set(gca,'YTickMode','manual','YTick',[0,1.0]); subplot(2,2,2); plot(w/pi, pha); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Phase Response in Radians'); subplot(2,2,4); plot(w/pi, grd*pi/180); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Group Delay');
set(gca,'XTickMode','manual','XTick',[0,0.25,1,1.75,2]);
%set(gca,'YTickMode','manual','YTick',[0,1.0]);
运行结果:
这里放d=0.1的运行结果。

二阶全通滤波器的留数、极点

系统零极点图,可以看出,两个零点都在单位圆外,幅角为π

方法一,利用系统函数直接形式,将脉冲序列做输入,得到脉冲响应h,得到系统幅度谱、相位谱和群延迟,如下图

方法二,将二阶全通系统函数部分分式展开,然后查表求逆z变换,得到脉冲响应h_chk


幅度谱、相位谱和群延迟,可以看到,ω=π时,幅度有衰减


可见,两种方法得到的脉冲响应h有区别,我们将各自前21个元素列出来,方框处二者稍有区别。
但,为何有区别,没搞懂,欢迎各位博友不吝赐教。

《DSP using MATLAB》Problem 8.11的更多相关文章
- 《DSP using MATLAB》Problem 7.11
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.11
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 5.11
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 4.11
代码: %% ---------------------------------------------------------------------------- %% Output Info a ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.6
代码: 子函数ampl_res function [Hr,w,P,L] = ampl_res(h); % % function [Hr,w,P,L] = Ampl_res(h) % Computes ...
- 《DSP using MATLAB》Problem 5.21
证明: 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 5.20
窗外的知了叽叽喳喳叫个不停,屋里温度应该有30°,伏天的日子难过啊! 频率域的方法来计算圆周移位 代码: 子函数的 function y = cirshftf(x, m, N) %% -------- ...
- 《DSP using MATLAB》Problem 5.14
说明:这两个小题的数学证明过程都不会,欢迎博友赐教. 直接上代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- [转]Visual Studio 各版本下载
原文地址:[置顶] Visual Studio 各版本下载 文件名称 文件大小 百度网盘下载 微软官方下载 Visual Studio 2015 Enterprise - 企业版 - 简体中文 3.8 ...
- The linux command之高级键盘技巧
一.光标移动 二.修改文本 三.剪切和粘贴文本 四.使用历史命令
- jq给页面添加覆盖层遮罩的实例
先引入jq代码,然后代码如下: $(function(){ var docHeight = $(document).height(); //获取窗口高度 $('body').append('<d ...
- 如何使用webpack 打包图片
最近在学习vue,需要用到webpack打包css,在webpack中文网https://www.webpackjs.com/里只有css的打包配置, 在编写css样式时,因为要引入 背景图片,打包时 ...
- Flink SQL 系列 | 5 个 TableEnvironment 我该用哪个?
本文为 Flink SQL 系列文章的第二篇,前面对 Flink 1.9 Table 新架构及 Planner 的使用进行了详细说明,本文详细讲解 5 个 TableEnvironment 及其适用场 ...
- Delphi让所有的窗口的标题和图标显示在任务栏上
Delphi:让所有的窗口的标题和图标显示在任务栏上在Delphi中,除了主窗口之外,当其它的窗口显示或切换到焦点时.默认情况下,窗口标题和图标并不会显示在任务栏中,为了实现像主窗口一样,每当窗口显示 ...
- LUOGU P4159 [SCOI2009]迷路(矩阵乘法)
传送门 解题思路 以前bpw讲过的一道题,顺便复习一下矩阵乘法.做法就是拆点,把每个点拆成\(9\)个点,然后挨个连边.之后若\(i\)与\(j\)之间的边长度为\(x\),就让\(i\)的第\(x\ ...
- json的dump和dumps的区别
dumps是将dict转化成str格式,loads是将str转化成dict格式. dump和load也是类似的功能,只是与文件操作结合起来了. In [1]: import json In [2]: ...
- vuex的使用入门-官方用例
store/index.js import Vue from 'vue' import Vuex from 'vuex'; // 使用vuex Vue.use(Vuex) const store = ...
- C# 串口编程 对端口的访问被拒绝
感谢Sunny秋刀鱼.https://www.cnblogs.com/527289276qq/p/5595798.html 在页面或者窗口Unloaded事件中关闭串口即可.