MATLAB Function Reference
  Go to function:
    Search    Help Desk 
dbstop    Examples   See Also

Set breakpoints in an M-file function

Syntax

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

The at, in, and if keywords, familiar to users of the UNIX debugger dbx, are optional.

Examples

The file buggy, used in these examples, consists of three lines.

Example 1 - Stop at First Executable Line

The statements

stop execution at the first executable line in buggy

The command

advances to the next line, at which point, you can examine the value of n.

Example 2 - Stop if Error

Because buggy only works on vectors, it produces an error if the input x is a full matrix. The statements

produce

and put MATLAB in debug mode.

Example 3 - Stop if Inf

In buggy, if any of the elements of the input x are zero, a division by zero occurs. The statements

produce

and put MATLAB in debug mode.

See Also

dbclear, dbcont, dbdown, dbquit, dbstack, dbstatus, dbstep, dbtype, dbup, partialpath



[ Previous | Help Desk | Next ]