MATLAB: Z Trandform matlab input

transformztransform

I have the following equation:
x(n)= 3(0.25^n)u(n)-(0.75^(n-1))u(n-1)
hot would I input this to solve using matlab?

Best Answer

If you have the Symbolic Math Toolbox:
syms n t z
u(n) = heaviside(n);
x(n)= 3*(0.25^n)*u(n)-(0.75^(n-1))*u(n-1);
X = ztrans(x, n, z); % Z-Transform
[Xn,Xd] = numden(X);
Xd = expand(Xd);
H(z) = Xn / Xd; % Transfer Function
H(z) =
-(- 48*z^3 + 40*z^2 + 17*z - 3)/(32*z^3 - 32*z^2 + 6*z)