Why am I getting "Error in fmincon (line 497) xIndices = classifyBo​undsOnVars​(l,u,sizes​.nVar,true​);" when running fmincon

2 views (last 30 days)
I am running a very simple code using matlab 2015b.
I create a simple function myfun as follows:
%------------------
function f = myfun(x)
f = f = (x(1)^2 + x(2)^2 + x(3)^2);
%-------------------
Then I have these two lines in a script:
x0 = [10;10;10];
[x,fval] = fmincon(@myfun,x0);
%-------------------
When I run this script, maltlab gives an error:
Undefined function or variable 'classifyBoundsOnVars'.
Error in fmincon (line 497)
xIndices = classifyBoundsOnVars(l,u,sizes.nVar,true);
Many thanks for your help.
  1 Comment
Yuebin Zhou
Yuebin Zhou on 25 Nov 2015
Use the following command and see if these functions are present on your computer.
>> which -all fmincon
>> which -all classifyBoundsOnVars
'fmincon' function does not come with base MATLAB but is in the Optimization toolbox, so please also check if you have this toolbox on your license.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!