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

  1. % function [out1,out2,out3,...] = veval(name,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.
  12. %      
  13. %   VEVAL can be used to easily generate VARYING system matrices.
  14. %
  15. %   See also: EVAL, FEVAL and VEBE.
  16.  
  17. function [out1,out2,out3,out4,out5,out6,out7,out8,out9,out10] =...
  18. veval(name,in1,in2,in3,in4,in5,in6,in7,in8,in9,in10,in11,in12,in13)
  19.  
  20.  if nargin == 0
  21.    disp('usage: [out1,out2,out3,...] = veval(in1,in2,in3,in4,...)')
  22.    return
  23.  end
  24.  
  25.  nin = nargin - 1;
  26.  nout = nargout;
  27.  
  28.  if nargout == 0
  29.    nout = 0;
  30.  end
  31.  
  32.  coldata = [];
  33.  rowdata = [];
  34.  typedata = [];
  35.  varyflg = 0;
  36.  for j=1:nin
  37.    eval(['[mtype,mrows,mcols,mnum] = minfo(in' int2str(j) ');']);
  38.      typedata = [typedata;mtype];
  39.      if mtype == 'vary'
  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.      elseif mtype == 'syst'
  55.          rowdata = [rowdata mnum+mrows+1];
  56.          coldata = [coldata mnum+mcols+1];
  57.      else
  58.          rowdata = [rowdata mrows];
  59.          coldata = [coldata mcols];
  60.      end
  61.  end
  62.  
  63.  if varyflg == 0
  64.    nindv = 1;
  65.  end
  66.  
  67.  pt = [];
  68.  ve = (0:(nindv-1))';
  69.  vee = (1:nindv)';
  70.  oness = ones(nindv,1);
  71.  for i=1:nin
  72.    if typedata(i,1:4) == 'vary'
  73.      pt = [pt oness+ve*rowdata(i) vee*rowdata(i)];
  74.    else
  75.      pt = [pt oness*[1 rowdata(i)]];
  76.    end
  77.  end
  78.  
  79.  istring = [];
  80.  if nargout > 0
  81.    ostring = ['['];
  82.    for j=1:nout
  83.      ostring = [ostring 'outt' int2str(j) ','];
  84.    end
  85.    ostring = ostring(1:length(ostring)-1);
  86.    ostring = [ostring '] = '];
  87.  else
  88.    ostring = ' ';
  89.  end
  90.  
  91.  for j=1:nin
  92.    istring = [istring 'inn' int2str(j) ','];
  93.  end
  94.  istring = istring(1:length(istring)-1);
  95.  
  96.  for j=1:nout
  97.    eval(['out' int2str(j) '= [];']);
  98.  end
  99.  
  100.  loc = '(pt(i,2*j-1):pt(i,2*j),1:coldata(j));';
  101.  for i=1:nindv
  102.    for j=1:nin
  103.      eval(['inn' int2str(j) '=in' int2str(j) loc]);
  104.    end
  105.    eval([ostring 'feval(''' name ''',' istring ');']);
  106.    for j=1:nout
  107.      eval(['out' int2str(j) '= [out' int2str(j) '; outt' int2str(j) '];']);
  108.    end
  109.  end
  110.  if varyflg == 1
  111.    for j=1:nout
  112.      eval(['out' int2str(j) '= vpck(out' int2str(j) ',indv);']);
  113.    end
  114.  end
  115. %
  116. % Copyright MUSYN INC 1991,  All Rights Reserved
  117.