Why do I obtain different results from the "Unconstrained Minimization" example within the documentation for the Optimization Toolbox?

The example that can be found at the documentation page generated by the command:
web([docroot '/toolbox/optim/tutoria7.html'])
states that the following commands:
x0 = [-1,1]; % Starting guess
options = optimset('LargeScale','off');
[x,fval,exitflag,output] = fminunc(@objfun,x0,options);
produce the solution:
x =
0.5000 -1.0000
...
However, I actually obtain the output:
Optimization terminated: relative infinity-norm of gradient less than options.TolFun.

 Accepted Answer

This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
The reason the commands do not show the output mentioned within the documentation is because of the ";" at the end of the last command. This ";" suppresses the expected output.
The message you are seeing is not an error message. It is a termination message that indicates the reason the optimization exited. These termination messages are shown, by default. To turn off these messages, change the "Display" option of "options" to "none" before supplying it to the FMINUNC function:
options = optimset(options,'Display','none');

More Answers (0)

Products

Release

R14SP1

Community Treasure Hunt

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

Start Hunting!