Filter löschen
Filter löschen

Fzero Exit Inf Value NaN

11 Ansichten (letzte 30 Tage)
James
James am 21 Jun. 2013
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 Kommentare
James
James am 24 Jun. 2013
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 am 24 Jun. 2013
Bearbeitet: Matt J am 24 Jun. 2013
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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 21 Jun. 2013
Bearbeitet: Matt J am 21 Jun. 2013
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]

Kategorien

Mehr zu Historical Contests finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by