poly2sym
Create symbolic polynomial from vector of coefficients
Description
Examples
Create Polynomial Expression
Create a polynomial expression from a symbolic vector of
coefficients. If you do not specify a polynomial variable,
poly2sym
uses x
.
syms a b c d p = poly2sym([a, b, c, d])
p = a*x^3 + b*x^2 + c*x + d
Create a polynomial expression from a symbolic vector of rational coefficients.
p = poly2sym(sym([1/2, -1/3, 1/4]))
p = x^2/2 - x/3 + 1/4
Create a polynomial expression from a numeric vector of floating-point coefficients. The toolbox converts floating-point coefficients to rational numbers before creating a polynomial expression.
p = poly2sym([0.75, -0.5, 0.25])
p = (3*x^2)/4 - x/2 + 1/4
Specify Polynomial Variable
Create a polynomial expression from a symbolic vector of
coefficients. Use t
as a polynomial variable.
syms a b c d t p = poly2sym([a, b, c, d], t)
p = a*t^3 + b*t^2 + c*t + d
To use a symbolic expression, such as t^2 + 1
or
exp(t)
, instead of a polynomial variable, substitute the
variable using subs
.
p1 = subs(p, t, t^2 + 1) p2 = subs(p, t, exp(t))
p1 = d + a*(t^2 + 1)^3 + b*(t^2 + 1)^2 + c*(t^2 + 1) p2 = d + c*exp(t) + a*exp(3*t) + b*exp(2*t)
Input Arguments
Output Arguments
Tips
Version History
Introduced before R2006a