p = poly2sym(c)
creates the symbolic polynomial expression p from the vector of
coefficients c. The polynomial variable is
x. If c = [c1,c2,...,cn], then p =
poly2sym(c) returns .
This syntax does not create the symbolic variable x in the
MATLAB® Workspace.
Create a polynomial expression from a symbolic vector of coefficients. If you do not specify a polynomial variable, poly2sym uses x.
syms abcd
p = poly2sym([a,b,c,d])
p =
Create a polynomial expression from a symbolic vector of rational coefficients.
p = poly2sym(sym([1/2,-1/3,1/4]))
p =
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.
Create a polynomial expression from a numeric vector of integer coefficients.
p_coeffs = [1 4 5 4 4];
p = poly2sym(p_coeffs)
p =
Because poly2sym does not create the symbolic variable x in the workspace, create this variable by using syms. Find the roots of the polynomial by using solve.
syms x
p_roots = solve(p,x)
p_roots =
The polynomial has 4 roots. To check if these roots are indeed the correct solution, you can reconstruct the original polynomial from the roots.
Find the factored form of the polynomial by subtracting each root from x.
p_elem = x-p_roots
p_elem =
Take the product of the factored form of the polynomial.
p_new = prod(p_elem)
p_new =
Expand the polynomial and confirm that the result is the same as the original expression.
When you call poly2sym for a numeric vector
c, the toolbox converts the numeric vector to a vector
of symbolic numbers using the default (rational) conversion mode of sym.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.