9.5 One-Sided Z-Transform Inverse
9.5.3 Inverse Z-Transform with MATLAB
Symbolic MATLAB can be used to compute the inverse one-sided Z-transform. The functioniztrans provides the sequence that corresponds to its argument. The following script illustrates the use of this function.
%%%%%%%%%%%%%%%%%%
% Inverse Z-transform
%%%%%%%%%%%%%%%%%%
syms n z
x1 = iztrans((z∗(z + 1))/((z + 0.5)∗(z - 0.5))) x2 = iztrans((2 - z)/(2∗(z - 0.5)))
x3 = iztrans((8 - 4∗z ˆ (-1))/(z ˆ (-2) + 6∗z ˆ (-1) + 8)) The above gives the following results:
x1 = 3/2∗(1/2) ˆ n - 1/2∗(-1/2) ˆ n x2 = -2∗charfcn[0](n) + 3/2∗(1/2) ˆ n x3 = -3∗(-1/4) ˆ n + 4∗(-1/2) ˆ n
Notice that the Z-transform can be given in positive or negative powers of z, and that when it is nonproper the functioncharfcn[0]corresponds toδ[n].
Partial Fraction Expansion with MATLAB
Several numerical functions are available in MATLAB to perform partial fraction expansion of a Z-transform and to obtain the corresponding inverse. In the following we consider the cases of single and multiple poles.
(1) Simple Poles
Consider finding the inverse Z-transform of
X(z)= z(z+1)
(z−0.5)(z+0.5)= (1+z−1)
(1−0.5z−1)(1+0.5z−1) |z|>0.5
The MATLAB functionresiduez provides the partial fraction expansion coefficients or residuesr[k], the polesp[k], and the gain kcorresponding toX(z)when the coefficients of its denominator and of its numerator are inputted. If the numerator or the denominator is given in a factored form (as is the case of the denominator above) we need to multiply the terms to obtain the denominator polynomial. Recall that multiplication of polynomials corresponds to convolution of the polynomial coefficients. Thus, to perform the multiplication of the terms in the denominator, we use the MATLAB functionconvto obtain the coefficients of the product. The convolution of the coefficients [1−0.5] of p1(z)=1−0.5z−1 and [1 0.5] ofp2(z)=1+0.5z−1 gives the denominator coefficients. By means of the MATLAB functionpoly we can obtain the polynomials in the numerator and denominator from the zeros and poles. These polynomials are then multiplied as indicated before to obtain the numerator with coefficients{b[k]}, and the denominator with coefficients{a[k]}.
To find the poles and the zeros ofX(z), given the coefficients{b[k]}and{a[k]}of the numerator and the denominator, we use the MATLAB functionroots. To get a plot of the poles and the zeros ofX(z), the MATLAB functionzplane, with inputs the coefficients of the numerator and the denominator of X(z), is used (conventionally, an’x’is used to denote poles and an’o’for zeros).
Two possible approaches can now be used to compute the inverse Z-transformx[n]. We can com- pute the inverse (below we call it x1[n] to differentiate it from the other possible solution, which we call x[n]) by using the information on the partial fraction expansion (the residues r[k]) and the corresponding poles. An alternative is to use the MATLAB functionfilter, which considersX(z) as a transfer function, with the numerator and the denominator defined by the b and a vectors of coefficients. If we assume the input is a delta function of Z-transform unity, the function filter computes as output the inverse Z-transformx[n] (i.e., we have tricked filter to give us the desired result).
The following script is used to implement the generation of the terms in the numerator and the denominator to obtain the corresponding coefficients, plot them, and find the inverse in the two different ways indicated above. For additional help on the functions used here usehelp.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Two methods for inverse Z-transform
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
p1 = poly(0.5); p2 = poly(-0.5); % generation of terms in denominator a = conv(p1,p2) % denominator coefficients
z1 = poly(0); z2 = poly(-1); % generation of terms in numerator b = conv(z1,z2) % numerator coefficients
z = roots(b) % zeros of X(z)
[r,p,k] = residuez(b,a) % partial fraction expansion, poles and gain zplane(b,a) % plot of poles and zeros
d = [1 zeros(1,99)]; % impulse delta[n]
x = filter(b,a,d); % x[n] computation from filter n = 0:99;
x1 = r(1)∗p(1). ˆ n + r(2)∗p(2). ˆ n; % x[n] computation from residues a = 1.0000 0 -0.2500
b = 1 1 0
z = 0 -1 r = 1.5000
-0.5000 p = 0.5000 -0.5000
Figure 9.9 displays the plot of the zeros and the poles and the comparison between the inversesx1[n]
andx[n] for 0≤n≤99, which coincide sample by sample.
9.5 One-Sided Z-Transform Inverse 549
−1 −0.5 0 0.5 1
−1.5
−1
−0.5 0 0.5 1 1.5
Real part
Imaginary part
0 5 10
(a) (b)
15 20
0 0.2 0.4 0.6 0.8 1
n x[n], x1[n]
FIGURE 9.9
(a) Poles and zeros ofX(z)and (b) inverse Z-transformsx[n]andx1[n]found usingfilterand the residues.
(2) Multiple Poles
Whenever multiple poles are present one has to be careful in interpreting the MATLAB results. First, use help to get more information onresiduez and how the partial fraction expansion for multiple poles is done. Notice from the help file that the residues are ordered the same way the poles are.
Furthermore, the residues corresponding to the multiple poles are ordered from the lowest to the highest order. Also notice the difference between the partial fraction expansion of MATLAB and ours.
For instance, consider the Z-transform
X(z)= az−1
(1−az−1)2 |z|>a
with inversex[n]=nanu[n]. Writing the partial fraction expansion as MATLAB does gives X(z)= r1
1−az−1 + r2
(1−az−1)2 r1= −1,r2=1 (9.33)
where the second term is not found in the Z-transforms table. To write it so that each of the terms in the expansion are in the Z-transforms table, we need to obtain values forAandBin the expansion
X(z)= A
1−az−1 + Bz−1
(1−az−1)2 (9.34)
so that Equations (9.33) and (9.34) are equal. We find that A=r1+r2, while B−Aa= −r1a or B=ar2. With these values we find the inverse to be
x[n]=[(r1+r2)an+nr2an]u[n]=nanu[n]
as expected.
To illustrate the computation of the inverse Z-transform from the residues in the case of multiple poles, consider the transfer function
X(z)= 0.5z−1
1−0.5z−1−0.25z−2+0.125z−3. The following script is used.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inverse Z-transform --- multiple poles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b = [0 0.5 0 0 ];
a = [1 -0.5 -0.25 0.125]
[r,p,k] = residuez(b,a) % partial fraction expansion, poles and gain zplane(b,a) % plot of poles and zeros
n = 0:99; xx = p(1). ˆ n; yy = xx.∗n;
x1 = (r(1) + r(2)).∗xx + r(2).∗yy + r(3)∗p(3). ˆ n; % inverse computation
The poles and the zeros and the inverse Z-transform are shown in Figure 9.10—there is a double pole at 0.5. The residues and the corresponding poles are
r = -0.2500 0.5000 -0.2500 p = 0.5000
0.5000 -0.5000
Computationally, our method and MATLAB’s are comparable but the inverse transform in our method is found directly from the table, while in the case of MATLAB’s you need to change the expansion to get it into the forms found in the tables.