companion
companion matrix
Syntax
A=companion(p)
Arguments
- p
double or polynomial vector
- A
square matrix
Description
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).
Examples
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
// p = x4 + 4x3 + 3x2 + 2x + 1 c = [1 4 3 2 1]; companion(c)
See also
- spec — eigenvalues, and eigenvectors of a matrix or a pencil
- poly — Polynomial definition from given roots or coefficients, or characteristic to a square matrix.
- randpencil — random pencil
History
| Version | Description |
| 2025.1.0 | companion now accepts a vector of polynomial coefficients. |
| Report an issue | ||
| << blockdiag | Matrix generation | diag >> |