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

  1. % function [out1,out2,out3,...] = mveval(name,mask,in1,in2,in3,...)
  2. %
  3. %   Works like MATLAB FEVAL, but on collections of VARYING and 
  4. %   CONSTANT/SYSTEM matrices. NAME is a character string with
  5. %   the name of a MATLAB function (user written, or MATLAB
  6. %   supplied).  The function is applied to each input argument
  7. %   at the INDEPENDENT VARIABLE's values. Any CONSTANT/SYSTEM
  8. %   matrices are held at their value while the sweep through
  9. %   INDEPENDENT VARIABLE is done. Currently limited to 10
  10. %   output arguments, and an unlucky 13 input arguments, which
  11. %   is easily changable. VEVAL can be used to easily generate
  12. %   VARYING system matrices.
  13. %
  14. %   See also: EVAL, FEVAL, VEBE, and VEVAL.
  15.  
  16. function [out1,out2,out3,out4,out5,out6,out7,out8,out9,out10] =...
  17. mveval(name,mask,in1,in2,in3,in4,in5,in6,in7,in8,in9,in10,in11,in12,in13)
  18.  
  19.  if nargin == 0
  20.    disp('usage: [out1,out2,out3,...] = mveval(name,mask,in1,in2,in3,in4,...)')
  21.    return
  22.  end
  23.  
  24.  nin = nargin - 2;    % CHANGED due to additional MASK input
  25.  nout = nargout;
  26.  
  27.  if nargout == 0
  28.    nout = 0;
  29.  end
  30.  
  31.  coldata = [];
  32.  rowdata = [];
  33.  typedata = [];
  34.  varyflg = 0;
  35.  for j=1:nin
  36.    eval(['[mtype,mrows,mcols,mnum] = minfo(in' int2str(j) ');']);
  37.      typedata = [typedata;mtype];
  38.      if mtype == 'vary'
  39.        if mask(j) > 0        % CHANGED
  40.          rowdata = [rowdata mrows];
  41.          coldata = [coldata mcols];
  42.          if varyflg == 0
  43.            firstvary = j;
  44.            nindv = mnum;
  45.            eval(['indv = getiv(in' int2str(j) ');']);
  46.            varyflg = 1;
  47.          else
  48.            eval(['code = indvcmp(in' int2str(firstvary) ',in' int2str(j) ');']);
  49.            if code ~= 1
  50.              error(['inconsistent varying data']);
  51.              return
  52.            end
  53.          end
  54.        else                    % ADDED THIS TO TREAT VARYING AS CONSTANT
  55.          rowdata = [rowdata mrows*mnum+1];    % ADDED THIS TO TREAT VARYING AS CONSTANT
  56.          coldata = [coldata mcols+1];        % ADDED THIS TO TREAT VARYING AS CONSTANT
  57.        end
  58.      elseif mtype == 'syst'
  59.          rowdata = [rowdata mnum+mrows+1];
  60.          coldata = [coldata mnum+mcols+1];
  61.      else
  62.          rowdata = [rowdata mrows];
  63.          coldata = [coldata mcols];
  64.      end
  65.  end
  66.  
  67.  if varyflg == 0
  68.    nindv = 1;
  69.  end
  70.  
  71.  pt = [];
  72.  ve = (0:(nindv-1))';
  73.  vee = (1:nindv)';
  74.  oness = ones(nindv,1);
  75.  for i=1:nin
  76.    if typedata(i,1:4) == 'vary'
  77.      pt = [pt oness+ve*rowdata(i) vee*rowdata(i)];
  78.    else
  79.      pt = [pt oness*[1 rowdata(i)]];
  80.    end
  81.  end
  82.  
  83.  istring = [];
  84.  if nargout > 0
  85.    ostring = ['['];
  86.    for j=1:nout
  87.      ostring = [ostring 'outt' int2str(j) ','];
  88.    end
  89.    ostring = ostring(1:length(ostring)-1);
  90.    ostring = [ostring '] = '];
  91.  else
  92.    ostring = ' ';
  93.  end
  94.  
  95.  for j=1:nin
  96.    istring = [istring 'inn' int2str(j) ','];
  97.  end
  98.  istring = istring(1:length(istring)-1);
  99.  
  100.  for j=1:nout
  101.    eval(['out' int2str(j) '= [];']);
  102.  end
  103.  
  104.  loc = '(pt(i,2*j-1):pt(i,2*j),1:coldata(j));';
  105.  for i=1:nindv
  106.    for j=1:nin
  107.      eval(['inn' int2str(j) '=in' int2str(j) loc]);
  108.    end
  109. %  ADJUSTED IT FROM HERE
  110.    if varyflg == 0
  111.      eval([ostring 'feval(''' name ''',' istring ');']);
  112.    else
  113.      tmask = mask - 1;
  114.      eval([ostring 'mveval(''' name ''',tmask,' istring ');']);
  115.    end
  116. %  TO HERE
  117.    for j=1:nout
  118.      eval(['out' int2str(j) '= [out' int2str(j) '; outt' int2str(j) '];']);
  119.    end
  120.  end
  121.  if varyflg == 1
  122.    for j=1:nout
  123.      eval(['out' int2str(j) '= vpck(out' int2str(j) ',indv);']);
  124.    end
  125.  end
  126. %
  127. % Copyright MUSYN INC 1991,  All Rights Reserved
  128.