代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.3 \n\n');
banner();
%% ------------------------------------------------------------------------ % Given resonat frequency and 3dB bandwidth
delta_omega = 0.05;
omega_r = 2*pi*0.375; r = 1 - delta_omega / 2
omega0 = acos(2*r*cos(omega_r)/(1+r*r)) % digital resonator
%r = 0.8
%r = 0.9
%r = 0.99
%omega0 = pi/4; % corresponding system function Direct form
% zeros at z=±1
G = (1-r)*sqrt(1+r*r-2*r*cos(2*omega0)) / sqrt(2*(1-cos(2*omega0))) % gain parameter
b = G*[1 0 -1]; % denominator
a = [1 -2*r*cos(omega0) r*r]; % numerator % precise resonant frequency and 3dB bandwidth
omega_r = acos((1+r*r)*cos(omega0)/(2*r));
delta_omega = 2*(1-r);
fprintf('\nResonant Freq is : %.4fpi unit, 3dB bandwidth is %.4f \n', omega_r/pi,delta_omega);
% [db, mag, pha, grd, w] = freqz_m(b, a); figure('NumberTitle', 'off', 'Name', 'Problem 8.3 Digital Resonator')
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.75,1,1.25,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.75,1,1.25,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.75,1,1.25,2]);
%set(gca,'YTickMode','manual','YTick',[0,1.0]); figure('NumberTitle', 'off', 'Name', 'Problem 8.3 Pole-Zero Plot')
set(gcf,'Color','white');
zplane(b,a);
title(sprintf('Pole-Zero Plot, r=%.3f %.2f\\pi',r,omega_r/pi));
%pzplotz(b,a); % Impulse Response
fprintf('\n----------------------------------');
fprintf('\nPartial fraction expansion method: \n');
[R, p, c] = residuez(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,200);
h_chk = filter(b,a,delta); % check sequences %h = ( 0.8.^n ) .* (2*0.232*cos(pi*n/4) - 2*0.0509*sin(pi*n/4)) -0.283 * delta; % r=0.8
%h = ( 0.9.^n ) .* (2*0.1063*cos(pi*n/4) - 2*0.0112*sin(pi*n/4)) -0.1174 * delta; % r=0.9
%h = ( 0.99.^n ) .* (2*0.0101*cos(pi*n/4) - 2*0.0001*sin(pi*n/4)) -0.0102 * delta; % r=0.99 h = ( 0.975.^n ) .* (2*0.0253*cos(pi*n*3/4) - 2*0.0006*sin(pi*n*3/4)) -0.026 * delta; % r=0.975 figure('NumberTitle', 'off', 'Name', 'Problem 8.3 Digital Resonator, 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.3 Digital Resonator, 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.75,1,1.25,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.75,1,1.25,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.75,1,1.25,2]);
%set(gca,'YTickMode','manual','YTick',[0,1.0]);

  运行结果:

系统函数部分分式展开,查表求逆z变换就可得到h(n)

零极点的模和幅角

将脉冲序列当成输入得到h_chk(n),系统函数求逆z变换得到h(n),

二者幅度谱、相位谱、群延迟对比如下,可见,幅度谱一样,相位谱和群延迟有所不同。

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

  1. 《DSP using MATLAB》Problem 7.27

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

  2. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

  3. 《DSP using MATLAB》Problem 7.25

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

  4. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  5. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  6. 《DSP using MATLAB》Problem 7.16

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

  7. 《DSP using MATLAB》Problem 7.15

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

  8. 《DSP using MATLAB》Problem 7.14

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

  9. 《DSP using MATLAB》Problem 7.13

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

  10. 《DSP using MATLAB》Problem 7.12

    阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. 一个很SB的方法,来开始调一个刚启动就SB的程序

    自己鼓捣的方法,累死我了... 遇到一个程序,这程序启动之后,会自动重新启动我的电脑, 我想调试它一下,但是遇到了问题, 如果我用调试器附加上去的话,电脑是不重起了,但是它启动了之后会立刻黑屏,全黑, ...

  2. 学无止境的CSS(xHTML+CSS技巧教程资源大全)

    本文里面收集一些有关CSS的技巧.教程.工具和观点等,其中一些你也许早就运用的炉火纯青,也可能有的你听都没听说过.不管是新手还是高手,大家都继续学习吧. 一,Web 标准 要玩游戏,就得先了解规则.要 ...

  3. 21-4indexOf

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. AM8不能下任何载附件及所有聊天记录无法登记

    问题描述: 接收附件时,点击打开或者下载都不成功,但可以发送消息和附件.但在消息管理器中,也查询不到发送和接收的消息 原因分析:此问题是windows开机登录用户权限问题(若 登录的账号是 whx), ...

  5. Eclipse注释快捷键、如何生成API以及可能遇到的问题解决

    1.Java注释方式单行注释// 快捷键:ctrl+/多行注释/* 快捷键:shift+ctrl+/*/文档注释/** 快捷键:shift+Alt+j */ 2.生成API文档 打开index.htm ...

  6. 跨域问题The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by t

    withCredentials 属性 上面说到,CORS请求默认不发送Cookie和HTTP认证信息.如果要把Cookie发到服务器,一方面要服务器同意,指定Access-Control-Allow- ...

  7. .net core, docker 在vs2019开发过程中的问题以及解决办法

    .net core, docker 在vs2019开发过程中的问题以及解决办法 记录下来,帮助Ta人~ 1.vs调试,快Build完后提示Docker 端口:xxxx,xxxx,xxxx占用 解决办法 ...

  8. ArrayList 和linkedList 插入比较

    从学Java开始, 就一直大脑记着  arrayList 底层是数组 ,查询快, 插入慢, 有移动的动作.linkedList 底层链表, 插入快 查询慢,今天写了例子跑了跑, 果然. public ...

  9. 跨数据库查询——dblink

    现在本地建一个dblink Create database link create public database link DBLINKTEST (名称) connect to MGP(用户名) i ...

  10. Redis Cluste部署

    一.原生搭建篇Cluster了解cluster的架构 Redis-cluster是使用的是一致性哈希算法来切分数据存储,总计16383个槽,分成16383/N(redis节点)个分区,存取时将key转 ...