- Did the code throw an error? If so what is the full and exact text of the error message (all the text displayed in red)? If you also received warning messages show all the warning text displayed in orange as well.
- Did the code give you a different answer than you expected? If so show the answer you received and the answer you expected and explain why you believe the answer you expected is the correct answer.
- Did MATLAB crash? If so please find the crash log file and send it to Technical Support for investigation.
- Did something else unexpected happen? If so, what happened?
Why option for fmincon is not working ?
5 views (last 30 days)
Show older comments
I defined the option as follows and it is not working. I tried many other options as well. Could anyone gives some idea ? Thanks
options = optimoptions('fmincon','Algorithm','interior-point','Display','iter-detailed',...
'MaxFunctionEvaluation',100000,'MaxIterations',2000,'FunctionTolerance',1e-10);
A=[]; b =[]; Aeq =[]; beq =[]; %x is vector
[V,fval,exitflag,output,lambda,grad,hessian] = fmincon(fun,x,A,b,Aeq,beq,LB,UB,options)
2 Comments
Steven Lord
on 6 Nov 2020
What does "not working" mean?
Accepted Answer
More Answers (1)
Steven Lord
on 6 Nov 2020
If you want to provide an options structure to fmincon you must provide all the input arguments that precede it. While you've passed in fun, x, A, b, Aeq, beq (these four as empty matrices), LB, and UB you haven't passed in nonlcon which is the nonlinear constraint function. The documentation page for fmincon provides this advice: "If there are no nonlinear inequality or equality constraints, set nonlcon = []."
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!