Matlab – Find z-transform and plot it’s pole-zero map with MATLAB

MATLABplot

I have this function:

x[n] = (1/2) ^ n * u[n] + (-1/3) ^ n * u[n]

I need to do two things with this using MATLAB:

  1. Find it's z-transform.

  2. Plot it's poles and zeros.

I am using the following code:

syms n;
f = (1/2)^n + (-1/3)^n;
F = ztrans(f);

I get the z-transform in the F variable, but I can't see how to create it's pole-zero plot. I am using the built-in function pzmap (pzmap(F);), but it doesn't seem to work with the output of ztrans(f).

What am I doing wrong? Do I need to change the z-transform into some other form like like a transfer function model or a zero-pole gain model? If so, can someone explain how that can be done using the output of ztrans(f)?

Best Answer

The first bit of code you gave uses symbolic math to solve for the z-transform. You'll need to convert the output to a discrete-time model supported by the Control System toolbox.

syms n;
f = (1/2)^n + (-1/3)^n;
F = ztrans(f)

returns z/(z - 1/2) + z/(z + 1/3). You can optionally use collect to convert this

F2 = collect(F)

to (12*z^2 - z)/(6*z^2 - z - 1). Then you'll want to find the coefficients of the polynomials in the numerator and denominator and create a discrete-time transfer function object with tf for a particular sampling period:

[num,den] = numden(F2);
Ts = 0.1; % Sampling period
H = tf(sym2poly(num),sym2poly(den),Ts)

Then pzmap(H) will produce a plot like this:

Pole-Zero Map plot

Related Topic