필터 지우기
필터 지우기

Fzero Exit Inf Value NaN

조회 수: 11 (최근 30일)
James
James 2013년 6월 21일
I am using the fzero function and at some points get the error:
Exiting fzero: aborting search for an interval containing a sign change because NaN or Inf function value encountered during search.
(Function value at -1.3492 is Inf.)
Check function or try again with a different starting value.
ans = NaN
Which looking at the matrix of values seems to be caused by where the function goes off to infinity so cannot find f=0 value as there is not one.
How can I resolve this problem? There is a little bit of code I can add in to get around this? At the moment those points on the contour plot are just white but expect to have something there.
  댓글 수: 3
James
James 2013년 6월 24일
update:
If I use the fzero command I get the above error that ans=NaN however if I just plot the function against the variable I can see that there is apparently a value of the variable for which the equation is zero. These two things contradict each other :s
Matt J
Matt J 2013년 6월 24일
편집: Matt J 2013년 6월 24일
These two things contradict each other
No, not really. For example, the function
sin(x)/x-1
goes to zero as x-->0, and the plot will appear to have a root at x=0. However, MATLAB behaves as follows,
>> sin(0)/0-1
ans =
NaN

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

답변 (1개)

Matt J
Matt J 2013년 6월 21일
편집: Matt J 2013년 6월 21일
as there is not one.
You seem to be saying here that the function has no root. If so, why is it a problem if the search fails? It is correctly telling you that no solution exists.
On the other hand, if you think FZERO is just searching in the wrong region, then the syntax
fzero(fun,[lb,ub])
will limit the search to the interval [lb,ub]

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by