This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Companion matrix


A = compan(u)


A = compan(u) returns the corresponding companion matrix whose first row is -u(2:n)/u(1), where u is a vector of polynomial coefficients. The eigenvalues of compan(u) are the roots of the polynomial.


collapse all

Compute the companion matrix corresponding to the polynomial (x-1)(x-2)(x+3)=x3-7x+6.

u = [1 0 -7 6];
A = compan(u)
A = 3×3

     0     7    -6
     1     0     0
     0     1     0

The eigenvalues of A are the polynomial roots.

ans = 3×1


Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

| | |

Introduced before R2006a