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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.