poly2sym
Builds a symbolic polynomial from a coefficient vector.
Category: Symbolic Computations in MATLAB > Conversion Between Symbolic and Numeric
Syntax
p = poly2sym(c)
Polynomial in the default variable x, with coefficients c, highest power first.
p = poly2sym(c, v)
Uses the symbolic variable v instead of x.
Description
The coefficient order is the same as polyval, roots and poly: the first entry multiplies the highest power. Numeric coefficients are converted to exact rational numbers, so 0.5 gives 1/2 instead of a decimal. Leading zeros are dropped.
It is the inverse of sym2poly.
Input arguments
c- Vector of coefficients, numeric or symbolic.
v- Symbolic variable or its name (optional).
Output arguments
p- Symbolic polynomial
c(1)*v^(n-1) + ... + c(n).
Example
Default and named variable
poly2sym([1 0 -1])
syms t
poly2sym([2 3], t)
poly2sym([1 0.5 0.25])
Output
ans = x^2 - 1
ans = 2*t + 3
ans = x^2 + x/2 + 1/4