代码:

%% ------------------------------------------------------------------------
%% 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. 1月28日周日,更新ruby到2.5.0版,rvm更新。

    在学习Array的方法的时候,发现文档concat方法可以进行多个数组的添加,而我的不行,猜测是ruby版本没有更新. 查询2.31ruby版本的concat方法,果然和2.5版本的不一样. 于是准备 ...

  2. The Number Games CodeForces - 980E (树, 贪心)

    链接 大意: 给定$n$节点树, 求删除$k$个节点, 使得删除后还为树, 且剩余点$\sum{2^i}$尽量大 维护一个集合$S$, 每次尽量添加最大的点即可 这样的话需要支持求点到集合的最短距离, ...

  3. python中的注意事项

    .python 中的 and 从左到右计算表达式,若所有值均为真,则返回最后一个值,若存在假,返回第一个假值: or 也是从左到有计算表达式,返回第一个为真的值: 其中数字 0 是假,其他都是真: 字 ...

  4. vijos1098 经典LIS变形

    合唱队形 描述 N位同学站成一排,音乐老师要请其中的(N-K)位同学出列,使得剩下的K位同学排成合唱队形. 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1,2…,K,他们的身高分别为T1, ...

  5. 对比springmvc与struts2

    转载:http://blog.csdn.net/chenleixing/article/details/44570681 1.Struts2是类级别的拦截, 一个类对应一个request上下文,Spr ...

  6. 自定义Spark Partitioner提升es-hadoop Bulk效率——续

    对于es 2.4版本,要能定制spark partitioner需要如下方式启动spark shell: spark-2.0.0-bin-hadoop2.6/bin/spark-shell --jar ...

  7. $digest already in progress 解决办法——续

    什么时候手动调用$apply()方法? 如果AngularJS总是将我们的代码wrap到一个function中并传入$apply(),以此来开始一轮$digest循环,那么什么时候才需要我们手动地调用 ...

  8. 清除mac出现的.DS_Store文件

    一.什么是.DS_Store文件 在 Mac OS X 系统下,大部分文件夹中都包含 .DS_Store 隐藏文件,这里保存着针对这个目录的特殊信息和设置配置,例如查看方式.图标大小以及这个目录的一些 ...

  9. 深入了解 Java-Netty高性能高并发理解

    https://www.jianshu.com/p/ac7fb5c2640f 一丶 Netty基础入门 Netty是一个高性能.异步事件驱动的NIO框架,它提供了对TCP.UDP和文件传输的支持,作为 ...

  10. PHP:第二章——PHP中的while语句

    <?php 语法格式: while(条件){ 代码块; } 说明:如果条件等价于true则重复执行代码块中内容,否则不执行 示例1: $i = ; ){ $i--; echo $i; } 注意: ...