필터 지우기
필터 지우기

How can I disable fminsearch function to print a warning message?

조회 수: 16 (최근 30일)
Merse Gaspar
Merse Gaspar 2023년 8월 29일
댓글: Steven Lord 2023년 8월 29일
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
Merse Gaspar
Merse Gaspar 2023년 8월 29일
As far as I know, this function does not use the standrad warning stuff. I has to do something with this:
MATLAB:optimfun:fminsearch:ExitingMaxFunctionEvals
But I don't know what is this, and how to disable it.
Steven Lord
Steven Lord 2023년 8월 29일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2023년 8월 29일
fminsearch(___, optimset('Display','off'))

추가 답변 (1개)

dpb
dpb 2023년 8월 29일
편집: dpb 2023년 8월 29일
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)
Exiting: Maximum number of iterations has been exceeded - increase MaxIter option. Current function value: 2.002182
x = 1×2
-0.3720 0.1037
lastwarn
ans = 0×0 empty char array
options = optimset('Display','final','MaxIter',20);
[x,~,~,s] = fminsearch(fun,x0,options);
Exiting: Maximum number of iterations has been exceeded - increase MaxIter option. Current function value: 2.002182
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

카테고리

Help CenterFile Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by