function Q=innerlp(outvar, intfcn, inmin, inmax, tol, method) 
%INNERLP Used with DBLQUAD to evaluate inner loop of integral.
%   Do not call this function directly; instead, call DBLQUAD, which then
%   calls this function. 
%
%   Q = INNERLP(OUTVAR,INTFCN,INMIN,INMAX,TOL,METHOD)
%   OUTVAR is the value(s) of the outer variable at which 
%   evaluation is desired, passed directly by QUAD. 
%   INTFCN is the name of the object function, passed indirectly 
%   from DBLQUAD. INMIN and INMAX are the integration limits for 
%   the inner variable, passed indirectly from DBLQUAD. 
%   TOL is passed to QUAD (QUAD8) when evaluating the inner 
%   loop, passed indirectly from DBLQUAD. The string METHOD determines 
%   what quadrature method is used, such as QUAD, QUAD8 or some
%   user-defined method.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.7 $  $Date: 1997/11/21 23:30:48 $

% Preallocate memory for the output variable. 
Q = ones(size(outvar)); 

% Evaluate the integrand function at each specified value of the 
% outer variable. 

trace = [];     % No trace for dblquad

if isequal(method, 'quad')
  for i=1:length(outvar) 
    Q(i)=quad(intfcn, inmin, inmax, tol, trace, outvar(i)); 
  end 
elseif isequal(method, 'quad8')
  for i=1:length(outvar) 
    Q(i)=quad8(intfcn, inmin, inmax, tol, trace, outvar(i)); 
  end 
else % call other user-defined quadrature method
  for i=1:length(outvar) 
    Q(i)=feval(method, intfcn, inmin, inmax, tol, trace, outvar(i)); 
  end 
end

