《DSP using MATLAB》Problem 8.3
代码:
%% ------------------------------------------------------------------------
%% 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的更多相关文章
- 《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 ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.15
用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.13
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.12
阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- JDBC_数据库连接池c3p0
/** * @Description: TODO(这里用一句话描述这个类的作用) * @Author aikang * @Date 2019/8/26 20:12 */ /* 1.数据库连接池: 1. ...
- next() 与 nextLine() 区别
next() 与 nextLine() 区别 next(): 1.一定要读取到有效字符后才可以结束输入. 2.对输入有效字符之前遇到的空白,next() 方法会自动将其去掉. 3.只有输入有效字符后才 ...
- bootstrap-----流体布局解析
流体布局容器 容器的width为auto,只是两边加了15px的padding. 流体布局容器 容器的width为auto,只是两边加了15px的padding. <div class=&quo ...
- jquery选择器中中>和空格的区别
空格:$('parent childchild')表示获取parent下的所有的childchild节点 大于号:$('parent > childchild')表示获取parent下的所有下一 ...
- JSONObject 序列化后,对象数据为引用地址
最近在json序列化的时候,遇到了个坑,记录如下: public static void main(String[] args) { JSONObject json = new JSONObject( ...
- Hibernate之Inverse的用法
在多的一端配置Inverse设置为true,来自动管理关系
- vue导航条选中项样式
html: <div id="app"> <div class="collection"> <a href="#!&qu ...
- Mysql之DQL------基础查询
#笔记内容来自于B站尚硅谷教学视频(av49181542)use myemployees; 查询表中的单个字段 SELECT last_name FROM employees; 查询表中的多个字段 # ...
- 【牛客Wannafly挑战赛12】小H和圣诞树
题目 可以考虑边分治,对于某一种颜色,我们处理出分治边左右两边所有以这个颜色为端点的路径长度,之后随便拼一拼就好了 但是这样对于每一组询问都需要边分一遍,这样做复杂度是\(O(nm+n\log n)\ ...
- where与having区别
解释一. 聚合函数是比较where.having 的关键. 开门见山.where.聚合函数.having 在from后面的执行顺序: where>聚合函数(sum,min,max,avg,cou ...