compan

Purpose

Companion matrix.

Synopsis

A = compan(p)

Description

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

The eigenvalues of compan(p) are the roots of the polynomial.

Examples

The polynomial

has a companion matrix given by

p = [1  0  -7  6]
A = compan(p)
          
A =
    0    7   -6
    1    0    0
    0    1    0
The eigenvalues are the polynomial roots:

eig(compan(p)) =
          
    -3.0000
     2.0000
     1.0000
This is also roots(p).

See Also

eig, poly, polyval, roots 

(c) Copyright 1994 by The MathWorks, Inc.