function [lambda,gf]=goalfun(V,neqcstr,FUNfcns,GRADfcns,WEIGHT,GOAL,x,varargin)
%GOALFUN Utility function to translate goal-attainment problem.
%
%   Intermediate function used to translate goal attainment
%   problem into constrained optimization problem.
%   Used by FGOALATTAIN, FMINIMAX and FMINCON (from private/NLCONST). 
%   
%   See also GOALCON.

%   Copyright 1990-2000 The MathWorks, Inc.
%   $Revision: 1.16 $  $Date: 2000/06/16 22:24:30 $
%   Andy Grace 7-9-90.

nx=length(V)-1;
% Assign V to x, keeping x to be its original length and width
x(:)=V(1:nx);

% Compute the objective function 
lambda=V(nx+1);   

if nargout > 1
   % Compute the gradient of the objective
   gf=[zeros(nx,1); 1];
end
