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:
-
Find it's z-transform.
-
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.
returns
z/(z - 1/2) + z/(z + 1/3)
. You can optionally usecollect
to convert thisto
(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 withtf
for a particular sampling period:Then
pzmap(H)
will produce a plot like this: