how to pass parameters to fmincon when using OutputFcn

Hello, I have one problem with the "fmincon". Thank you for any help. I have to pass some parameters 'a' to the objective function and constraints, if I do no need the "OutputFcn", just run "fmincon(@fun,x0,[],[],[],[],lb,ub,@nonlcon,options,a)".
If the "OutputFcn" has to be used for iterative info, the pervious command gives the error infomation as:
Error using ==> runfmincon>outfun
Too many input arguments.
Error in ==> callAllOptimOutputFcns at 12
stop(i) = feval(OutputFcn{i},xOutputfcn,optimValues,state,varargin{:});
Error in ==> nlconst>callOutputAndPlotFcns at 1056
stop = callAllOptimOutputFcns(outputfcn,xOrigShape,optimValues,state,varargin{:}) || stop;
Error in ==> nlconst at 608
[xOrigShape, optimValues, stop] = callOutputAndPlotFcns(outputfcn,plotfcns,caller,XOUT, ...
Error in ==> fmincon at 696
[X,FVAL,LAMBDA,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
Error in ==> runfmincon at 13
xsol = fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options,a);
what I can do to realize the paramter passing?
Thank you again!

Answers (1)

Do not pass "a" at the end of the fmincon list. Instead use anonymous functions to pass it. For example,
fmincon( @(x,t) objfun(x,t,a), x0, ...., options)

Categories

Find more on Programming in Help Center and File Exchange

Asked:

J T
on 21 Jun 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!