MATLAB: How do you get a symbolic answer for this z transform in MATLAB

z transform

I can't figure out how to type this in with the unit step delay
This is my current code:
syms n z;
F=ztrans(2*(n-2)+3*(n-3)*(1/(1-z^-1)));
F2=collect(F);
[num, dem] = numden(F2)
pretty(F2)
Ts=0.1;
H=tf(sym2poly(num),sym2poly(dem),Ts);
pzmap(H)

Best Answer

If I remember correctly, the z-transform of theDirac delta funciton is 1, so:
syms x n x(n) z
x(n) = 2*dirac(n-2) + 3*heaviside(n-3)
X = ztrans(x, n, z)
X = subs(X, {ztrans(dirac(n), n, z)}, {1})
producing:
X =
3/(z^3*(z - 1)) + 2/z^2
Continuing:
Xe = expand(X);
[num,den] = numden(Xe);
num = simplify(num, 'Steps',10)
den = simplify(den, 'Steps',10)
nd = sym2poly(num);
dd = sym2poly(den);
Ts = 0.1;
H = tf(nd, dd, Ts)
figure
bode(H)
figure
pzmap(H)
creates the Control System Toolbox ‘H’ system object, and the plots.