代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 4.20 \n\n'); banner();
%% ------------------------------------------------------------------------ % ----------------------------------------------------
% 1 H1(z)
% ---------------------------------------------------- b = [1, 0, 0, 0, -1]*0.82805;
a = [1, 0, 0, 0, -0.81*0.81]; % [R, p, C] = residuez(b,a) Mp = (abs(p))'
Ap = (angle(p))'/pi %% ------------------------------------------------------
%% START a determine H(z) and sketch
%% ------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P4.20 H(z) its pole-zero plot')
set(gcf,'Color','white');
zplane(b,a);
title('pole-zero plot'); grid on; %% ----------------------------------------------
%% END
%% ---------------------------------------------- % ------------------------------------
% h(n)
% ------------------------------------ [delta, n] = impseq(0, 0, 7);
h_check = filter(b, a, delta) % check sequence h_answer = 1.2621*impseq(0,0,7) ...
- 0.1085*(0.9*j).^n.*stepseq(0,0,7) - 0.1085*(-0.9*j).^n.*stepseq(0,0,7) ...
- 0.1085*(0.9).^n.*stepseq(0,0,7) - 0.1085*(-0.9).^n.*stepseq(0,0,7) % answer sequence %% --------------------------------------------------------------
%% START b |H| <H
%% 3rd form of freqz
%% --------------------------------------------------------------
w = [-500:1:500]*pi/500; H = freqz(b,a,w);
%[H,w] = freqz(b,a,200,'whole'); % 3rd form of freqz magH = abs(H); angH = angle(H); realH = real(H); imagH = imag(H); %% ================================================
%% START H's mag ang real imag
%% ================================================
figure('NumberTitle', 'off', 'Name', 'P4.20 DTFT and Real Imaginary Part ');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magH); grid on; %axis([0,1,0,1.5]);
title('Magnitude Response');
xlabel('frequency in \pi units'); ylabel('Magnitude |H|');
subplot(2,2,3); plot(w/pi, angH/pi); grid on; % axis([-1,1,-1,1]);
title('Phase Response');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realH); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagH); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% ==================================================
%% END H's mag ang real imag
%% ================================================== %% =========================================================
%% Steady-State and Transient Response
%% =========================================================
bx = [1, -sqrt(2)/2]; ax = [1, -sqrt(2), 1]; by = 0.82805*conv(b, bx)
ay = conv(a, ax) [R, p, C] = residuez(by, ay) Mp_Y = (abs(p))'
Ap_Y = (angle(p))'/pi %% ------------------------------------------------------
%% START a determine Y(z) and sketch
%% ------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P4.20 Y(z) its pole-zero plot')
set(gcf,'Color','white');
zplane(by, ay);
title('pole-zero plot'); grid on; % ------------------------------------
% y(n)
% ------------------------------------ LENGTH = 50; [delta, n] = impseq(0, 0, LENGTH-1);
y_check = filter(by, ay, delta); % check sequence y_answer = ( 2*0.414.*(cos(pi*n/4)) - 0.029*(0.9).^n ...
+ (-2*0.0356*(0.9).^n.*cos(pi*n/2) - 2*0.0625*(0.9).^n.*sin(pi*n/2) ...
- 0.0422*(-0.9).^n ) ) .* stepseq(0,0,LENGTH-1); yss = 2*0.414.*(cos(pi*n/4)) .* stepseq(0,0,LENGTH-1);
yts = - 0.029*(0.9).^n ...
+ (-2*0.0356*(0.9).^n.*cos(pi*n/2) - 2*0.0625*(0.9).^n.*sin(pi*n/2) ...
- 0.0422*(-0.9).^n ) .* stepseq(0,0,LENGTH-1); figure('NumberTitle', 'off', 'Name', 'P4.20 Yss and Yts ');
set(gcf,'Color','white');
subplot(2,1,1); stem(n, yss); grid on; %axis([0,1,0,1.5]);
title('Steady-State Response');
xlabel('n'); ylabel('Yss');
subplot(2,1,2); stem(n, yts); grid on; % axis([-1,1,-1,1]);
title('Transient Response');
xlabel('n'); ylabel('Yts'); figure('NumberTitle', 'off', 'Name', 'P4.20 Y(n) ');
set(gcf,'Color','white');
subplot(1,1,1); stem(n, y_answer); grid on; %axis([0,1,0,1.5]);
title('Total Response');
xlabel('n'); ylabel('Y(n)');

  运行结果:

系统函数的零极点图如下,4个极点都位于单位圆内。

全部输出的z变换,Y(z)的零极点图如下,单位圆上的极点和稳态输出有关,单位圆内部的极点和暂态输出有关。

这里显示输出的前50个元素,下面是全输出:

稳态输出和暂态输出如下图:

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

  1. 《DSP using MATLAB》Problem 6.20

    先放子函数: function [C, B, A, rM] = dir2fs_r(h, r); % DIRECT-form to Frequency Sampling form conversion ...

  2. 《DSP using MATLAB》Problem 5.20

    窗外的知了叽叽喳喳叫个不停,屋里温度应该有30°,伏天的日子难过啊! 频率域的方法来计算圆周移位 代码: 子函数的 function y = cirshftf(x, m, N) %% -------- ...

  3. 《DSP using MATLAB》Problem 3.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  4. 《DSP using MATLAB》Problem 2.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  5. 《DSP using MATLAB》Problem 7.24

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

  6. 《DSP using MATLAB》Problem 7.23

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

  7. 《DSP using MATLAB》Problem 6.15

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

  8. 《DSP using MATLAB》Problem 6.12

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

  9. 《DSP using MATLAB》Problem 6.10

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

随机推荐

  1. 详解Mybatis通用Mapper介绍与使用

    使用Mybatis的开发者,大多数都会遇到一个问题,就是要写大量的SQL在xml文件中,除了特殊的业务逻辑SQL之外,还有大量结构类似的增删改查SQL.而且,当数据库表结构改动时,对应的所有SQL以及 ...

  2. Confluence 6 获得 Active Directory 服务器证书

    上面的步骤说明了如何在你的 Microsoft Active Directory服务器上安装 certification authority (CA).这一步,你需要为你的 Microsoft Act ...

  3. python-day6---运算符

    #了解部分#字符串+,*#列表:+,*# l1=[1,2,3]# l2=[4,5]## print(l1+l2)# print(l1*3) #比较运算符# num1=3# num2=1 # print ...

  4. JS水平移动图片

    横向: <div id=demo style="overflow:hidden;width:200px;border:2px solid #e0e0e0;padding:2px;&qu ...

  5. 数据库SQL优化(百万级数据库优化方案)

    1. 对查询进行优化 要尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2. where 子句 要尽量避免在 where 子句中对字段进行 null 值判断.( ...

  6. SQL优化(SQL TUNING)可大幅提升性能的实战技巧之一——让计划沿着索引跑

    我们进行SQL优化时,经常会碰到对大量数据集进行排序,然后从排序后的集合取前部分结果的需求,这种情况下,当我们按照常规思路去写SQL时,系统会先读取过滤获得所有集合,然后进行排序,再从排序结果取出极少 ...

  7. JVM笔记(一) Java内存区域

    Java 内存区域 总概 java虚拟机在执行java程序的过程中,会把它管理的内存划分为几个不同的数据区域.每当运行一个java程序时,就会启动一个虚拟机. 具体的区域如图所示: 同时,方法区 与 ...

  8. vuex2.0+两个小例子

    首先vuex概念比较多,一定要搞懂里面的概念,可以参考官网Vuex2.0概念,我写此文的目的是希望能对前端爱好者提供个参考,加深对vuex2.0各核心概念的理解. 废话少说,直接上干货.这是官网上的一 ...

  9. kill word out 1

    1● de 使~~ 成为 :离开 ,去掉,向下,变慢   2● dif 不,分开 ,否定,离开     3● deci 十分之一   4● deca 向下,离开   5● deca 十   6● di ...

  10. POJ 2057 The Lost Home 树形dp 难度:2

    The Lost House Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 2203   Accepted: 906 Des ...