How to get polynomial by the given root in MatLab? - poly -- MatLab
How to get polynomial by the given root in MatLab? - poly -- MatLab
How to get polynomial by the given root in MatLab?
[Ans]
poly
[description]
(1)
<pr_coef>=poly(<pr_vec>);
It will return coefficients of polynomial with specified roots of polynomial.
<pr_coef>
coefficients of polynomial.
vector type.
<pr_vec>
specified roots of polynomial.
vector type.
(2)
<pr_M>=poly(<M>)
Let M is be a N by N matrix.
pr_M is a row vector with N+1 elements which are the coefficients of the
characteristic polynomial.
It is computed by det(lambda*eye(size(M)) - M).
<pr_M>
pr_M is coefficients of characterist polynomial.
vector type.
<M>
roots of polynomial
Square-Matrix type.
more details on:
code:
clear
clc
pr=[1:6] %root of polynomial
poly1=poly(pr) %cooefficient of polynomial given by pr.
fprintf("1\n");
%{
output:
pr =
1 2 3 4 5 6
poly1 =
Columns 1 through 6
1 -21 175 -735 1624 -1764
Column 7
720
%}
%means the polynomial is:x^6-21*x^5+175*x^4-735*x^3+1624*x^2-1764*x+720=0
pr_M=[1 3 4 4;4 6 7 8; 3 7 8 9; 2 7 9 3]
poly_M=poly(pr_M)
rootPoly_M=roots(poly_M)%get root of pr_vec.
fprintf("2\n");
%{
output:
pr_M =
1 3 4 4
4 6 7 8
3 7 8 9
2 7 9 3
poly_M =
1.0000 -18.0000 -111.0000 -75.0000 -37.0000
rootPoly_M =
22.9762 + 0.0000i
-4.2859 + 0.0000i
-0.3452 + 0.5066i
-0.3452 - 0.5066i
%}
Comments
Post a Comment