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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.