home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / SPECMAT.DI$ / COMPAN.M next >
Encoding:
Text File  |  1993-03-07  |  449 b   |  21 lines

  1. function A = compan (c)
  2. %COMPAN    Companion matrix.
  3. %    COMPAN(P) is a companion matrix of the polynomial
  4. %    with coefficients P.
  5.  
  6. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  7.  
  8. if min(size(c)) > 1
  9.     error('Input argument must be a vector.')
  10. end
  11. n = length(c);
  12. if n <= 1
  13.    A = [];
  14. elseif n == 2
  15.    A = -c(2)/c(1);
  16. else
  17.    c = c(:).';     % make sure it's a row vector
  18.    A = diag(ones(1,n-2),-1);
  19.    A(1,:) = -c(2:n) ./ c(1);
  20. end
  21.