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

  1. % function matout = xtracti(mat,ivindex)
  2. %
  3. %   If MAT is a VARYING matrix, and IVINDEX is a 
  4. %   positive integer, with IVINDEX <= LENGTH(GETIV(MAT)),
  5. %   then MATOUT is the matrix associated with
  6. %   the IVINDEX'th INDEPENDENT VARIABLE's value.
  7. %   This applies to the top level independent variable,
  8. %   in the case of nested IV's.
  9. %   If MAT is a CONSTANT or SYSTEM matrix, and INDVINDX is a
  10. %   positive integer, then MATOUT is equal to MAT.
  11. %
  12. %   See also: GETIV, MINFO, SCLIV, SEL, VAR2CON, and XTRACT.
  13.  
  14. %   modified for NESTED VARYING MATRICES, ivindex should
  15. %    be a vector reflecting desired iv value at each level,
  16. %    as usual, from slowest to fastest.
  17.  
  18. function matout = xtracti(mat,indvnum)
  19.   err = 0;
  20.   if nargin < 2
  21.     disp('usage: matout = xtracti(mat,ivindex)')
  22.     return
  23.   end
  24.   if indvnum <= 0 | floor(indvnum) ~= ceil(indvnum)
  25.     error('INDEPENDENT VARIABLE index should be a positive integer')
  26.     return
  27.   end
  28.   matout = mat;
  29.   [mtype,mrows,mcols,mnum] = minfo(matout);
  30.   if strcmp(mtype,'vary')
  31.     if mnum >= indvnum(1)
  32.       matout = matout((indvnum-1)*mrows+1:indvnum*mrows,1:mcols);
  33.       if length(indvnum) > 1
  34.         indvnum = indvnum(2:length(indvnum));
  35.         matout = xtracti(matout,indvnum);
  36.       end
  37.     else
  38.       error('INDEPENDENT VARIABLE index too large for VARYING data')
  39.       return
  40.     end
  41.   else
  42.     matout = mat;
  43.   end
  44. %
  45. % Copyright MUSYN INC 1991,  All Rights Reserved
  46.