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

  1. % function out = vrank(mat)
  2. %
  3. %   Rank of a VARYING/CONSTANT matrix.
  4. %   Identical to MATLAB's RANK command, but works
  5. %   with VARYING matrices also.
  6. %
  7. %   See also: COND, RANK, SVD, VCOND, VNORM, VRCOND and VSVD. 
  8.  
  9. function out = vrank(mat)
  10.   if nargin == 0
  11.     disp('usage: out = vrank(mat)')
  12.     return
  13.   end
  14.   [mtype,mrows,mcols,mnum] = minfo(mat);
  15.   [nr,nc] = size(mat);
  16.     if mtype == 'cons'
  17.       out = rank(mat);
  18.     elseif mtype == 'vary'
  19.       omega = mat(1:mnum,nc);
  20.       npts = mnum;
  21.       nrout = 1;
  22.       ncout = 1;
  23.       out = zeros(npts+1,ncout+1);
  24.       out(npts+1,ncout+1) = inf;
  25.       out(npts+1,ncout) = npts;
  26.       out(1:npts,ncout+1) = omega;
  27.       ftop = (npts+1)*mrows;
  28.       ptop = 1:mrows:ftop;
  29.       ptopm1 = ptop(2:npts+1) - 1;
  30.       for i=1:npts
  31.         out(i,1) = rank(mat(ptop(i):ptopm1(i),1:mcols));
  32.       end
  33.     elseif mtype == 'syst'
  34.       error('VRANK is undefined for SYSTEM matrices')
  35.       return
  36.     else
  37.       out = [];
  38.     end
  39. %
  40. % Copyright MUSYN INC 1991,  All Rights Reserved
  41.