MATLAB: Polynomial coefficients in descending powers of s

algorithmMATLABpolynomialvector

How do I extract the polynomial coefficients of s? ( s = tf('s') )
For example, p= 4 s^4 – s^3 + 8 s^2 + 9.
I want to get the vector [4 -1 8 0 9]
Function "coeffs" doesn't work : Undefined function 'coeffs' for input arguments of type 'tf'.

Best Answer

  • Try this:
    s = tf('s');
    p = 4*s^4 - s^3 + 8*s^2 + 9;
    coefficients = p.Numerator{:}
    producing:
    coefficients =
    4 -1 8 0 9
    .