How can I disable fminsearch function to print a warning message?
Show older comments
warning('off') is not workink. Why? I get the following message: Exiting: Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. But I want to ignore, and desable printing it.
2 Comments
Merse Gaspar
on 29 Aug 2023
Steven Lord
on 29 Aug 2023
As far as I know, this function does not use the standrad warning stuff.
That is correct. This message is not a warning.
I has to do something with this:
MATLAB:optimfun:fminsearch:ExitingMaxFunctionEvals
But I don't know what is this, and how to disable it.
That allows MATLAB to retrieve localized text for certain languages and certain text in the MATLAB Desktop.
Accepted Answer
More Answers (1)
options = optimset('MaxIter',20);
fun = @(x)100*(x(2) - x(1)^2)^2 + (1 - x(1))^2;
x0 = [-1.2,1];
x = fminsearch(fun,x0,options)
lastwarn
options = optimset('Display','final','MaxIter',20);
[x,~,~,s] = fminsearch(fun,x0,options);
options = optimset('Display','none','MaxIter',20);
[x,~,e,s] = fminsearch(fun,x0,options);
warning('off') doesn't work because the message isn't a warning; it's a normal informative output message.
As the above shows, the only way to suppress it is to turn output off entirely and then retrieve the result from the output variable. The exit flag variable, e will be 0 if this is the cause or the message content itself is a member of the output struct, s
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!