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

  1. % function [out1,out2,out3,...] = vveval(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).
  7. %
  8. %    If in1, in2, ... in_last are all either CONSTANT or
  9. %    SYSTEM matrices, then VVEVAL calls the function specified
  10. %    by the variable NAME, using FEVAL.
  11. %
  12. %   If any of in1, in2, ... in_n are VARYING, say in_K, then VVEVAL
  13. %   checks that all of the VARYING data is the same, and performs
  14. %   a loop, recursively calling itself in the following manner
  15. %
  16. %
  17. %   out1 = [];
  18. %      .
  19. %   outm = [];
  20. %   for i=1:length(getiv(in_K))
  21. %     [t1,t2,..,tm] = vveval(xtracti(in1,i),xtracti(in2,i),.,xtracti(in_n,i);
  22. %     out1 = [out1;t1];
  23. %     out2 = [out2;t2];
  24. %     outm = [outm;tm];
  25. %   end
  26. %   out1 = vpck(out1,ivvalue);
  27. %   out2 = vpck(out2,ivvalue);
  28. %   outm = vpck(outm,ivvalue);
  29. %
  30. %   See also: EVAL, FEVAL, SWAPIV, VEVAL, and MVEVAL.
  31.  
  32. function [out1,out2,out3,out4,out5,out6,out7,out8,out9,out10] =...
  33. vveval(name,in1,in2,in3,in4,in5,in6,in7,in8,in9,in10,in11,in12,in13)
  34.  
  35.  if nargin == 0
  36.    disp('usage: [out1,out2,out3,...] = vveval(name,in1,in2,in3,in4,...)')
  37.    return
  38.  end
  39.  
  40.  nin = nargin - 1;
  41.  nout = nargout;
  42.  
  43.  if nargout == 0
  44.    nout = 0;
  45.  end
  46.  
  47.  coldata = [];
  48.  rowdata = [];
  49.  typedata = [];
  50.  varyflg = 0;
  51.  for j=1:nin
  52.    eval(['[mtype,mrows,mcols,mnum] = minfo(in' int2str(j) ');']);
  53.      typedata = [typedata;mtype];
  54.      if mtype == 'vary'
  55.          rowdata = [rowdata mrows];
  56.          coldata = [coldata mcols];
  57.          if varyflg == 0
  58.            firstvary = j;
  59.            nindv = mnum;
  60.            eval(['indv = getiv(in' int2str(j) ');']);
  61.            varyflg = 1;
  62.          else
  63.            eval(['code = indvcmp(in' int2str(firstvary) ',in' int2str(j) ');']);
  64.            if code ~= 1
  65.              error(['inconsistent varying data']);
  66.              return
  67.            end
  68.          end
  69.      elseif mtype == 'syst'
  70.          rowdata = [rowdata mnum+mrows+1];
  71.          coldata = [coldata mnum+mcols+1];
  72.      else
  73.          rowdata = [rowdata mrows];
  74.          coldata = [coldata mcols];
  75.      end
  76.  end
  77.  
  78.  if varyflg == 0
  79.    nindv = 1;
  80.  end
  81.  
  82.  pt = [];
  83.  ve = (0:(nindv-1))';
  84.  vee = (1:nindv)';
  85.  oness = ones(nindv,1);
  86.  for i=1:nin
  87.    if typedata(i,1:4) == 'vary'
  88.      pt = [pt oness+ve*rowdata(i) vee*rowdata(i)];
  89.    else
  90.      pt = [pt oness*[1 rowdata(i)]];
  91.    end
  92.  end
  93.  
  94.  istring = [];
  95.  if nargout > 0
  96.    ostring = ['['];
  97.    for j=1:nout
  98.      ostring = [ostring 'outt' int2str(j) ','];
  99.    end
  100.    ostring = ostring(1:length(ostring)-1);
  101.    ostring = [ostring '] = '];
  102.  else
  103.    ostring = ' ';
  104.  end
  105.  
  106.  for j=1:nin
  107.    istring = [istring 'inn' int2str(j) ','];
  108.  end
  109.  istring = istring(1:length(istring)-1);
  110.  
  111.  for j=1:nout
  112.    eval(['out' int2str(j) '= [];']);
  113.  end
  114.  
  115.  loc = '(pt(i,2*j-1):pt(i,2*j),1:coldata(j));';
  116.  for i=1:nindv
  117.    for j=1:nin
  118.      eval(['inn' int2str(j) '=in' int2str(j) loc]);
  119.    end
  120. %  adjusted it here
  121.    if varyflg == 0
  122.      eval([ostring 'feval(''' name ''',' istring ');']);
  123.    else
  124.      eval([ostring 'vveval(''' name ''',' istring ');']);
  125.    end
  126. %  to here
  127.    for j=1:nout
  128.      eval(['out' int2str(j) '= [out' int2str(j) '; outt' int2str(j) '];']);
  129.    end
  130.  end
  131.  if varyflg == 1
  132.    for j=1:nout
  133.      eval(['out' int2str(j) '= vpck(out' int2str(j) ',indv);']);
  134.    end
  135.  end
  136. %
  137. % Copyright MUSYN INC 1991,  All Rights Reserved
  138.