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

  1. % function [mattype,rowd,cold,num] = minfo(mat)
  2. %  or
  3. % function  minfo(mat)
  4. %
  5. %   Return information about a matrix and provides a consistency 
  6. %   check for CONSTANT, SYSTEM and VARYING matrices.
  7. %
  8. %   See also: PCK, PSS2SYS, SYS2PSS, UNPCK, and VUNPCK.
  9.  
  10. function [mattype,rowd,cold,num] = minfo(mat)
  11.   if nargout == 2 | nargout == 3 | nargin ~= 1
  12.     disp('usage: [mattype,rowdata,coldata,num] = minfo(mat)');
  13.   else
  14.     if isempty(mat)
  15.       flg = 3;
  16.     else
  17.       [nr,nc] = size(mat);
  18.       if nr == 1 | nc == 1
  19.         flg = -1;
  20.       else
  21.         flg = 0;
  22.         states = mat(1,nc);
  23.         if any(real(mat(2:nr-1,nc))) | any(imag(mat(2:nr-1,nc))) | ...
  24.           any(real(mat(nr,1:nc-1))) | any(imag(mat(nr,1:nc-1)))
  25.           flg = -2;
  26.         elseif states < 0 | mat(nr,nc) ~= -inf
  27.           flg = -2;
  28.         elseif  floor(states) ~= ceil(states)
  29.           flg = -2;
  30.         elseif states >= min([nr,nc])-1
  31.           flg = -2;
  32.         end
  33.         if flg == 0
  34.           flg = 1;
  35.         else
  36.           npts = mat(nr,nc-1);
  37.           if  floor(npts) ~= ceil(npts) | npts <= 0
  38.             flg = -3;
  39.           elseif npts >= nr | mat(nr,nc) ~= inf
  40.             flg = -3;
  41.           elseif  any(real(mat(npts+1:nr-1,nc))) | ...
  42.              any(imag(mat(npts+1:nr-1,nc))) | any(real(mat(nr,1:nc-2))) | ...
  43.              any(imag(mat(nr,1:nc-2)))
  44.             flg = -3;
  45.           end
  46.           if flg == -2
  47.             nrr = round((nr-1)/npts);
  48.             if nrr*npts == nr-1
  49.               flg = 2;
  50.             end
  51.           end
  52.         end
  53.       end
  54.     end
  55.   end
  56.  if nargout ~= 4
  57.    if flg < 0
  58.      disp([int2str(nr) ' rows  ' int2str(nc) ' cols: regular MATLAB matrix'])
  59.    elseif flg == 1
  60.      no = nr-1-states;
  61.      ni = nc-1-states;
  62.      lab1 = ['system:   '];
  63.      lab2 = [int2str(states) ' states     '];
  64.      lab3 = [int2str(no) ' outputs     '];
  65.      lab4 = [int2str(ni) ' inputs     '];
  66.      disp([lab1 lab2 lab3 lab4])
  67.    elseif flg == 2
  68.      cols=nc-1;
  69.      lab1 = ['varying:   '];
  70.      lab2 = [int2str(npts) ' pts     '];
  71.      lab3 = [int2str(nrr) ' rows     '];
  72.      lab4 = [int2str(cols) ' cols     '];
  73.      disp([lab1 lab2 lab3 lab4])
  74.    elseif flg == 3
  75.      disp(['empty matrix']);
  76.    end
  77.  else
  78.    if flg < 0
  79. %    constant matrix
  80.      mattype = 'cons';
  81.      rowd = nr;
  82.      cold = nc;
  83.      num = 0;
  84.    elseif flg == 1
  85. %    system matrix
  86.      mattype = 'syst';
  87.      rowd = nr-1-states;
  88.      cold = nc-1-states;
  89.      num = states;
  90.    elseif flg == 2
  91. %    varying matrix
  92.      mattype = 'vary';
  93.      rowd = nrr;
  94.      cold = nc-1;
  95.      num = npts;
  96.    elseif flg == 3
  97. %    empty matrix
  98.      mattype = 'empt';
  99.      rowd = 0;
  100.      cold = 0;
  101.      num = 0;
  102.    end
  103.  end
  104. %
  105. % Copyright MUSYN INC 1991,  All Rights Reserved
  106.