home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 2.ddi / MUTOOLS1.DI$ / VPOLY.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.2 KB  |  49 lines

  1. % function out = vpoly(mat)
  2. %
  3. %   Characteristic polynomial of a VARYING/CONSTANT
  4. %   matrix. Identical to MATLAB's POLY command, but 
  5. %   works with VARYING matrices also.
  6. %
  7. %   See also: DET, POLY, ROOTS, VDET, and VROOTS.
  8.  
  9. function out = vpoly(mat)
  10.   if nargin == 0
  11.     disp('usage: out = vpoly(mat)')
  12.     return
  13.   end
  14.   [mtype,mrows,mcols,mnum] = minfo(mat);
  15.   [nr,nc] = size(mat);
  16.   if mrows == mcols
  17.     if mtype == 'cons'
  18.       out = poly(mat);
  19.     elseif mtype == 'vary'
  20.       npts = mnum;
  21.       ncout = mcols + 1;
  22.       out = zeros(npts+1,ncout+1);
  23.       ftop = (npts+1)*mrows;
  24.       ptop = 1:mrows:ftop;
  25.       ptopm1 = ptop(2:npts+1) - 1;
  26.       for i=1:npts
  27.         out(i,1:ncout) = poly(mat(ptop(i):ptopm1(i),1:mcols));
  28.       end
  29.       out(1:npts,ncout+1) = mat(1:mnum,nc);
  30.       out(npts+1,ncout+1) = inf;
  31.       out(npts+1,ncout) = npts;
  32.     elseif mtype == 'syst'
  33.       error('VPOLY is undefined for SYSTEM matrices')
  34.       return
  35.     else
  36.       out = [];
  37.     end
  38.   else
  39.     if mtype == 'syst'
  40.       error('VPOLY is undefined for SYSTEM matrices')
  41.       return
  42.     else
  43.       error('input matrix must be square for VPOLY')
  44.       return
  45.     end
  46.   end
  47. %
  48. % Copyright MUSYN INC 1991,  All Rights Reserved
  49.