home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / POLYFUN.DI$ / POLYVALM.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  605 b   |  24 lines

  1. function y = polyvalm(c,x)
  2. %POLYVALM Matrix polynomial evaluation.
  3. %    If  V  is a vector whose elements are the coefficients of a
  4. %    polynomial,  then   POLYVALM(V,X)   is  the   value  of  the
  5. %    polynomial evaluated with matrix argument X.  See POLYVAL
  6. %    for polynomial evaluation in the regular or array sense.
  7.  
  8.  
  9. %    J.N.Little 4-20-86
  10. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  11.  
  12. % Polynomial evaluation c(x) using Horner's method 
  13.  
  14. nc = max(size(c));
  15. [m,n] = size(x);
  16. if m ~= n
  17.     error('Matrix must be square.')
  18. end
  19.  
  20. y = zeros(m);
  21. for i=1:nc
  22.     y = x * y + c(i) * eye(m);
  23. end
  24.