9 |; n7 u+ p/ V% Qimpz(...) with no output arguments plots the impulse response of the filter. & H7 U2 |# p6 h5 s$ S7 k5 h % q/ N% n/ b. n( m" ^, q意思是直接画出该系统的脉冲响应。4 v d/ a- _# v
X7 e4 [+ l: D) q5 n2 c5 d4 u9 L; f
上面两种方法画出的脉冲响应其实是一样的。 8 u3 I! s' _+ H! n; R0 @ 4 H1 M8 k8 N* _- Q% s! L上面这个简单的用法也就告一段落,下面我们再看一条变体语法: & b9 k2 o3 K. ^, k, d3 b $ ^0 A2 Z. p/ n/ L. ]- V/ y; |; x0 p, N[h,t] = impz(...,n) computes n samples of the impulse response when n is an integer (t = [0:n-1]'). If n is a vector of integers, impz computes the impulse response at those integer locations, starting the response computation from 0 (and t = n or t = [0 n]). If, instead of n, you include the empty vector, [], for the second argument, the number of samples is computed automatically.: z9 L3 r8 ^* c& m2 [: U- Z+ z
只看语法格式,那么一大串英文介绍暂时不管,后面我会慢慢解释。 " Q& }0 N. M' V% P1 M W, e; O: Y ( a! v$ ^* K7 { Q6 w[h,t] = impz(...,n) ! m/ p/ ?+ W' {1 U) |/ R. C, n( M; x
后面的这个n是什么玩意?; h% u% F/ X& z: M, B, e, P
( E0 R. p G: E {( g2 d; I
它的用意我用自己的语言叙述下就是如果我要求的脉冲响应不是从0开始,那么我就可以使用这个n向量来指定脉冲响应的位置范围。 o. a& m/ n, F. J' }" b- g2 \) e! k4 y/ S* Y3 S
同样使用一个实例来说明,同样是上面的那个差分方程表示的系统,我们求它的脉冲响应。 . U; E. e/ `1 v8 j. u / I( e& g2 [( `5 C& X这个系统使用差分方程来描述如下: ! b) y! F6 y3 H) H% F1 c 1 s% @) G/ O: h; ^y(n) - y(n-1) + 0.9y(n-2) = x(n) ; t3 p4 V6 z5 B' k, M) p# A5 e 8 l, H, S% L; C; v. D7 M& v# k9 d要求计算并画出在n = -20,...,100 的脉冲响应h(n)。 3 L5 W( q7 `% b9 n 1 Q8 n8 V8 b7 {. t5 l2 h; u) N脚本程序如下:9 j+ a4 B+ x( o7 _: z
6 V% t' V: y- ?0 ]6 X3 K8 q
clc
clear
close all
b = [1];
a = [1,-1,0.9];
n = [-20:120]';
impz(b,a,n);
ylim([-1.2,1.2]);$ y6 j) n6 [1 b9 V& L" L/ m
- J8 _# s, O" p8 ~* u( N2 Z9 m, R/ E0 B {8 \4 s, N, n4 @7 @