Customize dbstop in MATLAB

If you use the editor, you can set a stop as normal, right-click on it, select “set/modify condition” and enter the condition (the stop will turn from red to yellow).

From command line, you can use

dbstop in file if expression
dbstop in file at location if expression

e.g.
dbstop in myFile at 200 if (~isempty(var) && var > 3)

as mentioned by @LuisMendo.

The second option may be more useful, since the first one seems to be only evaluated at the start of the file. In other words, it doesn’t seem to be possible to have a similarly generic expression as dbstop if naninf that checks for certain values across an entire file.

Leave a Comment