| MATLAB Function Reference | Search  Help Desk |
| dbstop | Examples See Also |
Set breakpoints in an M-file function
Syntax
dbstop in mfile dbstop in mfile at lineno dbstop in mfile at subfun dbstop if error dbstop if warning dbstop if naninf dbstop if infnan
Description
dbstop in mfile
temporarily stops execution of mfile when you run it, at the first executable line, putting MATLAB in debug mode. If you have graphical debugging enabled, the MATLAB Debugger opens with a breakpoint at the first executable line of mfile. You can then use the debugging utilities, review the workspace, or issue any valid MATLAB command. Use dbcont or dbstep to resume execution of mfile. Use dbquit to exit from the Debugger.
dbstop in mfile at lineno
temporarily stops execution of mfile when you run it, just prior to execution of the line whose number is lineno, putting MATLAB in debug mode. If you have graphical debugging enabled, the MATLAB Debugger opens mfile with a breakpoint at line lineno. If that line is not executable, execution stops and the breakpoint is set at the next executable line following lineno. When execution stops, you can use the debugging utilities, review the workspace, or issue any valid MATLAB command. Use dbcont or dbstep to resume execution of mfile. Use dbquit to exit from the Debugger.
dbstop in mfile at subfun
temporarily stops execution of mfile when you run it, just prior to execution of the subfunction subfun, putting MATLAB in debug mode. If you have graphical debugging enabled, the MATLAB Debugger opens mfile with a breakpoint at the subfunction specified by subfun. You can then use the debugging utilities, review the workspace, or issue any valid MATLAB command. Use dbcont or dbstep to resume execution of mfile. Use dbquit to exit from the Debugger.
dbstop if error
stops execution when any M-file you subsequently run produces a run-time error, putting MATLAB in debug mode, paused at the line that generated the error. You cannot resume execution after an error. Use dbquit to exit from the Debugger.
dbstop if warning
stops execution when any M-file you subsequently run produces a run-time warning, putting MATLAB in debug mode, paused at the line that generated the warning. Use dbcont or dbstep to resume execution.
dbstop if naninf
stops execution when any M-file you subsequently run encounters an infinite value (Inf), putting MATLAB in debug mode, paused at the line where Inf was encountered. Use dbcont or dbstep to resume execution. Use dbquit to exit from the Debugger.
dbstop if infnan
stops execution when any M-file you subsequently run encounters a value that is not a number (NaN), putting MATLAB in debug mode, paused at the line where NaN was encountered. Use dbcont or dbstep to resume execution. Use dbquit to exit from the Debugger.
Remarks
Theat, in, and if keywords, familiar to users of the UNIX debugger dbx, are optional.
Examples
The filebuggy, used in these examples, consists of three lines.
function z = buggy(x) n = length(x); z = (1:n)./x;
Example 1 - Stop at First Executable Line
The statementsdbstop in buggy buggy(2:5)stop execution at the first executable line in buggy
n = length(x);The command
dbstepadvances to the next line, at which point, you can examine the value of
n.
Example 2 - Stop if Error
Becausebuggy only works on vectors, it produces an error if the input x is a full matrix. The statements
dbstop if error buggy(magic(3))produce
??? Error using ==> ./ Matrix dimensions must agree. Error in ==> c:\buggy.m On line 3 ==> z = (1:n)./x; K»and put MATLAB in debug mode.
Example 3 - Stop if Inf
Inbuggy, if any of the elements of the input x are zero, a division by zero occurs. The statements
dbstop if naninf buggy(0:2)produce
Warning: Divide by zero. > In c:\buggy.m at line 3 K»and put MATLAB in debug mode.
See Also
dbclear, dbcont, dbdown, dbquit, dbstack, dbstatus, dbstep, dbtype, dbup, partialpath