Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

sym2poly

Extract vector of all numeric coefficients, including zeros, from symbolic polynomial

Syntax

c = sym2poly(p)

Description

example

c = sym2poly(p) returns the numeric vector of coefficients c of the symbolic polynomial p. The returned vector c includes all coefficients, including those equal 0.

sym2poly returns coefficients in order of descending powers of the polynomial variable. If c1xn1+c2xn2+...+cn, then c = sym2poly(p) returns c = [c1 c2 ... cn].

Examples

Extract Numeric Coefficients of Polynomial

Create row vectors of coefficients of symbolic polynomials.

Extract integer coefficients of a symbolic polynomial into a numeric row vector.

syms x
c = sym2poly(x^3 - 2*x - 5)
c =
     1     0    -2    -5

Extract rational and integer coefficients of a symbolic polynomial into a vector. Because sym2poly returns numeric double-precision results, it approximates exact rational coefficients with double-precision numbers.

c = sym2poly(1/2*x^3 - 2/3*x - 5)
c =
    0.5000         0   -0.6667   -5.0000

Input Arguments

collapse all

Polynomial, specified as a symbolic expression.

Output Arguments

collapse all

Polynomial coefficients, returned as a numeric row vector.

Tips

  • To extract symbolic coefficients of a polynomial, use coeffs. This function returns a symbolic vector of coefficients and omits all zeros. For example, syms a b x; c = coeffs(a*x^3 - 5*b,x) returns c = [ -5*b, a].

See Also

|

Introduced before R2006a

Was this topic helpful?