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

  1. % function sysout = reordsys(sys,index);
  2. %
  3. %   Reorders the states of the SYSTEM matrix SYS as defined
  4. %   by position variables in INDEX. The INDEX variable must be 
  5. %   of the same size as the number of states of SYS.
  6. %
  7. %   See also: STRANS, SRESID, and TRUNC.
  8.  
  9. function [sysout,ssysout] = reordsys(sys,index);
  10.  if nargin ~= 2
  11.    disp('usage: sysout = reordsys(sys,index)')
  12.    return
  13.  end
  14.  
  15. [mtype,mrows,mcols,mnum] = minfo(sys);
  16.  
  17. if mtype == 'syst'
  18.   [a,b,c,d] = unpck(sys);
  19.   mat = zeros(mnum);
  20.   [nri,nci] = size(index);
  21.   if nri == mnum & nci == 1
  22.     index = index.';
  23.     if sort(index) ~= [1:mnum]
  24.       error('INDEX is incorrect')
  25.       return
  26.     end
  27.   elseif nci == mnum & nri == 1
  28.     if sort(index) ~= [1:mnum]
  29.       error('INDEX is incorrect')
  30.       return
  31.     end
  32.   else
  33.     error('INDEX is wrong size')
  34.     return
  35.   end
  36.   aax = a(index,index);
  37.   bbx = b(index,:);
  38.   ccx = c(:,index);
  39.   sysout = pck(aax,bbx,ccx,d);
  40. else
  41.   error('input matrix is not a SYSTEM matrix')
  42.   return
  43. end
  44. %
  45. % Copyright MUSYN INC 1991,  All Rights Reserved
  46.