代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.8 \n\n');
banner();
%% ------------------------------------------------------------------------ % digital iir highpass filter
b = [1 -1];
a = [1 -0.9]; figure('NumberTitle', 'off', 'Name', 'Problem 8.8 Pole-Zero Plot')
set(gcf,'Color','white');
zplane(b,a);
title(sprintf('Pole-Zero Plot'));
%pzplotz(b,a); % corresponding system function Direct form
K = 1; % gain parameter
b = K*b; % denominator
a = a; % numerator [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/gain1
[db, mag, pha, grd, w] = freqz_m(K*b, a); figure('NumberTitle', 'off', 'Name', 'Problem 8.8 IIR highpass 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]); % 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,50);
h_chk = filter(K*b,a,delta); % check sequences % ------------------------------------------------------------------------------------------------
% gain parameter K=0.95
% ------------------------------------------------------------------------------------------------
h = ( 0.9.^n ) .* (-0.1056) + 1.0556 * delta;
% ------------------------------------------------------------------------------------------------ figure('NumberTitle', 'off', 'Name', 'Problem 8.8 IIR hp 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.8 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]); % --------------------------------------------------
% digital IIR comb filter
% --------------------------------------------------
b = K*[1 0 0 0 0 0 -1];
a = [1 0 0 0 0 0 -0.9]; figure('NumberTitle', 'off', 'Name', 'Problem 8.8 Pole-Zero Plot')
set(gcf,'Color','white');
zplane(b,a);
title(sprintf('Pole-Zero Plot')); [db, mag, pha, grd, w] = freqz_m(b, a); figure('NumberTitle', 'off', 'Name', 'Problem 8.8 IIR comb 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]); % 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,250);
h_chk = filter(b,a,delta); % check sequences % ------------------------------------------------------------------------------------------------
% gain parameter K=0.95
% ------------------------------------------------------------------------------------------------
%h = 0.0211 * (( 0.9791.^n ) .* (2*cos(0.4*pi*n) + 2*cos(0.8*pi*n) + 1)) - 0.0556*delta; %L=5;
h = -0.0176 * ( ( 0.9826.^n ) .* ( 2*cos(2*pi*n/3) + 2*cos(pi*n/3) + (-1).^n + 1) ) + 1.0556*delta; %L=6;
% ------------------------------------------------------------------------------------------------ figure('NumberTitle', 'off', 'Name', 'Problem 8.8 Comb 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.8 Comb 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]);

  运行结果:

增益系数K

单个iir高通滤波器,零极点图

L=6阶梳状,系统函数部分分式展开

零极点的模和幅角

直接形式分子、分母系数直接求幅度谱、相位谱和群延迟

依据梳状滤波器系统函数部分分式展开,求逆z变换得到脉冲响应序列,由其求幅度谱、相位谱和群延迟,如下

直接形式求法和逆z变换求法,幅度谱、相位谱一致,但群延迟不同。

最新文章

  1. OC的runtime运行机制
  2. Google earth
  3. HDU 2836 (离散化DP+区间优化)
  4. 鼠标选择文字事件js代码,增加层问题
  5. 网站后台的lnmp启动与重启
  6. openfire的smack和asmack
  7. 关于Aggregate 的一点用法
  8. 文字排版--斜体(font-style)
  9. 使用UIPageControl UIScrollView制作APP引导界面
  10. winform 读取保存配置文件
  11. system strategies of Resources Deadlock
  12. nefu 449 超级楼梯 &amp;&amp;nefu 911 跨楼梯
  13. Python第一天接触心得
  14. shiro Filter--拦截器
  15. hdu 5012(bfs)
  16. Gleb And Pizza CodeForces - 842B
  17. 从Random Walk谈到Bacterial foraging optimization algorithm(BFOA),再谈到Ramdom Walk Graph Segmentation图分割算法
  18. Beta冲刺吐槽&amp;&amp;获小黄衫心得
  19. 【APP测试(Android)】--用户体验
  20. 传输SO10 (SO10 Transport)

热门文章

  1. (十七)从UML角度来理解依赖
  2. JAVA API about HTTP 3
  3. mysql DOS中中文乱码 ERROR 1366 (HY000): Incorrect string value: &#39;\xC4\xEA\xBC\xB6&#39; for column &#39;xxx&#39; at row 1
  4. iOS 工程实现native 跳转指定的Flutter 页面
  5. iOS开发系列-Runtime运用场景
  6. Linux内存 mem 和 swap
  7. 【数位DP】CF55D Beautiful numbers
  8. 修改sql server表字段的字符串
  9. hive 总结三(压缩)
  10. zookeeper 选举白话理解