MATLAB: Matlab extract coefficient from z transform function

ztransform

Hi I have a z transform function 3/z + 5/z^2 + 6/z^3 + 1
How would I extract the coefficients from this equation? I have tried using coeffs and it says it is not a polynomial.
I would like the answer to come out as [3 5 6 1]
The symbolic z variable is declared as syms z

Best Answer

Use the sym2poly function, although here it’s necesary to do an intermediate step:
syms z
fz = 3/z + 5/z^2 + 6/z^3 + 1
[fzn, fzd] = numden(fz)
fzc = sym2poly(fzn)
fzc = circshift(fzc, [0 -1])
produces:
fzc =
3 5 6 1