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

17 views (last 30 days)
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)

Accepted Answer

Star Strider
Star Strider on 17 Nov 2018
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.

More Answers (1)

Paul
Paul on 15 Dec 2024 at 18:55
With the default symbolic preferences
sympref('default');
We have
heaviside(0),disp(char(ans))
ans = 0.5000
So the discrete-time unit step function is (we could also change the sympref so that heaviside(0) = 1)
syms x n x(n) u(n) z
u(n) = heaviside(n) + kroneckerDelta(n)/2;
Define x[n] and take its z-transform
x(n) = 2*kroneckerDelta(n-2) + 3*u(n-3);
X = ztrans(x, n, z);
[num,den] = numden(X);X = num/den,pretty(X)
2 z + 1 ---------- 2 z (z - 1)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!