필터 지우기
필터 지우기

because NaN or Inf function value encountered during search while using fzero

조회 수: 7 (최근 30일)
I have a nonlinear equation---5e6-5e6*(exp(-aa*xt)-exp(-bb*xt))/(exp(-aa*1e-6)-exp(-bb*1e-6))=0
I am thinking is that due to the function is too nonlinear, and fzero cannot find the result?
For reference, the results should be 1e-6
aa=810930;
bb=1216395;
func = @(xt) 5e6-5e6*(exp(-aa*xt)-exp(-bb*xt))/(exp(-aa*1e-6)-exp(-bb*1e-6));
x0 = 0.00001;
roots = fzero(func,x0)
Exiting fzero: aborting search for an interval containing a sign change because NaN or Inf function value encountered during search. (Function value at -0.0008092 is Inf.) Check function or try again with a different starting value.
roots = NaN

채택된 답변

Matt J
Matt J 2022년 6월 2일
편집: Matt J 2022년 6월 2일
The problem occurs because func() has no axis crossing.
aa=810930;
bb=1216395;
func = @(xt) 5e6-5e6*(exp(-aa*xt)-exp(-bb*xt))/(exp(-aa*1e-6)-exp(-bb*1e-6));
x0 = 0.00001;
fplot(func,[0,10e-6])
Based on the plot, it appears you should be looking for the minimum of func() rather than a root.
xmin=fminsearch(func,x0)
xmin = 1.0000e-06

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Optimization에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by