Fzero Exit Inf Value NaN
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 21 de Jun. de 2013
What would "get around this" look like to you? If the function goes off to infinity without a zero, then what would you like to be returned at that location ?
Is your function "smooth"? Continuously differentiable? Available in symbolic form?
James
el 24 de Jun. de 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
Respuestas (1)
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]
Categorías
Más información sobre Performance and Memory en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!