I know its a stupid question, but I have no idea how to solve it… Lets say I have something like:
x = fmincon(@myfun,x0,A,b,Aeq,beq,lb,ub,@mycon)
and later on :
function [c,ceq] = mycon(x)
c = ...
ceq = ...
How to pass additional variables into @mycon, such as
function [c,ceq] = mycon(x, variable)
if variable == 1
c = ...
ceq = ...
else
c = ...
ceq = ...
end
Thanks 🙂
You pass
myconas anonymous function:Note that
variableis fixed at the moment thefminconline is called.