Skip to Main Content Skip to Search
Product Documentation

compan - Companion matrix

Syntax

A = compan(u)

Description

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.

Examples

The polynomial (x – 1)(x – 2)(x + 3) = x3 – 7x + 6 has a companion matrix given by

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

The eigenvalues are the polynomial roots:

eig(compan(u))

ans = 
    -3.0000
     2.0000
     1.0000

This is also roots(u).

See Also

eig | poly | polyval | roots

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS