I sometimes unknowingly generate values which are NaN and later on it may cause unexpected problems. I want to catch occurances of NaN or Inf without manually inserting isnan and isinf everywhere. When I use
dbstop if naninf
I have the following problem: dbstop will stop in all sorts of built-in matlab functions. But I only want dbstop to stop when it finds NaN or inf in a variable that is in the scope of the main function I wrote. How do I change this or is there an alternate way to catch unwanted occurances of NaN/inf? Thanks.
No products are associated with this question.
If it's a particular variable you're interested in, you can set a conditional breakpoint using a dbstop syntax like
dbstop in file if any(isnan(A(:))
Or you can set the breakpoint GUI-style in the MATLAB editor as described here http://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html#brqxeeu-234.