companion matrix
A=companion(p)
double or polynomial vector
square matrix
A = companion(p) with p which is a vector of polynomial coefficients returns the companion matrix. The coefficients must be in order of decreasing degree.
Returns a matrix A with characteristic polynomial equal
to p if p is monic. If p is not monic
the characteristic polynomial of A is equal to
p/c where c is the coefficient of largest degree
in p.
If p is a vector of monic polynomials, A is block diagonal,
and the characteristic polynomial of the ith block is p(i).
Companion matrix created from a polynom
s=poly(0,'s'); p=poly([1,2,3,4,1],'s','c') c = companion(p) det(s*eye(4,4)-c) roots(p) spec(companion(p)) | ![]() | ![]() |
Companion matrix created from vector of polynomial coefficients
| Version | Description |
| 2025.1.0 | companion now accepts a vector of polynomial coefficients. |