代码:

%% ------------------------------------------------------------------------
%% 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. javaScript 的 map() reduce() foreach() filter()

    map(映射), reduce(规约), forEach(遍历), filter(过滤),它们都是高阶函数,都是以传入不同的函数来以不同的方式操作数组元.ie都不支持 一.map方法 *概述 map( ...

  2. Confluence 6 使用 LDAP 授权连接到 Confluence 内部目录

    希望连接一个内部目录但是使用 LDAP 检查登录授权: 在屏幕的右上角单击 控制台按钮 ,然后选择 General Configuration 链接. 单击左侧面板上面的 用户目录(User Dire ...

  3. C++中的this指针

    1.关于this指针的一个精典回答: 当你进入一个房子后,你可以看见桌子.椅子.地板等,但是房子你是看不到全貌了.对于一个类的实例来说,你可以看到它的成员函数.成员变量,但是实例本身呢?this是一个 ...

  4. 42. Trapping Rain Water *HARD*

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  5. zk请求和响应对

    zk的请求和响应是通过id对应上的: 请求头(RequestHeader)和响应头(ReplyHeader)共用一个xid,它的本质是ClientCnxn类中的一个计数器. 1. 首先看客户端: Pa ...

  6. python中字符串连接的四种方式

    以下实例展示了join()的使用方法 #!/usr/bin/python str = "-"; seq = ("a", "b", " ...

  7. jenkins邮件配置----jenkins笔记(三)

    转载地址:https://www.cnblogs.com/sylvia-liu/p/4527390.html 前言 最近搭建Maven+Testng+jenkins的持续集成环境,希望最后实现自动邮件 ...

  8. openshift rhc

    Microsoft Windows [Version 6.1.7601]Copyright (c) 2009 Microsoft Corporation. All rights reserved. C ...

  9. sgu 121. Bridges painting 列举情况 难度:1

    121. Bridges painting time limit per test: 0.25 sec. memory limit per test: 4096 KB New Berland cons ...

  10. 用sql + Ado设置access的字段的默认值

    procedure TFormLOrder.ModifyDB; var F: Integer; begin with TADOQuery.Create(nil) do try // Connectio ...