From: Danyang on

I am trying to use matlab fmincon function:
the objective function is: simulator.runSimulation(vector); and it doesn't run. I figured the reason being that to define a class method, I have to add class name as a variable, e.g. a=runSimulation(simulator, vector). Here we have two arguments, which does not work with fmincon.The runSimulation function is very complicated, and there is no way of pulling it out of the class. Can anyone show me how to avoid that problem? much thanks!
From: Steven Lord on

"Danyang " <fnosdy(a)umich.edu> wrote in message
news:hsisqo$ge5$1(a)fred.mathworks.com...
>
> I am trying to use matlab fmincon function: the objective function is:
> simulator.runSimulation(vector); and it doesn't run. I figured the reason
> being that to define a class method, I have to add class name as a
> variable, e.g. a=runSimulation(simulator, vector). Here we have two
> arguments, which does not work with fmincon.The runSimulation function is
> very complicated, and there is no way of pulling it out of the class. Can
> anyone show me how to avoid that problem? much thanks!

Assuming you're using MATLAB 7.0 (R14) or later:

fmincon(@(vector) runSimulation(simulator, vector), ...)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ