I'm trying to specify an output function in my optimization options as an anonymous function so as to pass additional parameters to it. My options structure is defined as follows:
options = optimset('outputfcn',@(x)outfun(x,extraArg),'display','iter',... 'Algorithm','active-set');...function stop = outfun(x,optimValues,state,extraarg)......end % nested function
As a result, I get the following error:
??? Error using ==> runfminsearch>@(x)myfunObj(x,k1,k2,k3) Too many input arguments.
I need to pass additional arguments to an output function using an anonymous function.
Best Answer