Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

dbclear

Remove breakpoints

Syntax

  • dbclear all

Description

dbclear all removes all breakpoints in all MATLAB® code files, and all breakpoints set for errors, caught errors, caught error identifiers, warnings, warning identifiers, and naninf.

example

dbclear in file removes all breakpoints in file. The in keyword is optional.

example

dbclear in file at location removes the breakpoint set at the specified location in file. The at or in keywords are optional.

example

dbclear if condition removes all breakpoints set using the specified condition, such as dbstop if error or dbstop if naninf.

Examples

collapse all

Clear Breakpoints in File

Set and then clear breakpoints in a program file.

Create a file, buggy.m, that contains these statements.

function z = buggy(x)
n = length(x);
z = (1:n)./x;

Add breakpoints at line 2 and line 3. List all breakpoints using dbstatus.

dbstop in buggy at 2
dbstop in buggy at 3
dbstatus
Breakpoints for buggy are on lines  2, 3.

Remove all the breakpoints in buggy.m. Call dbstatus to ensure that all breakpoints are cleared.

dbclear in buggy
dbstatus

Clear Breakpoints in File at Location

Set and then clear breakpoints in a program file at a certain location.

Create a file, buggy.m, that contains these statements.

function z = buggy(x)
n = length(x);
z = (1:n)./x;

Add a breakpoint at line 2 and line 3. List all breakpoints using dbstatus.

dbstop in buggy at 2
dbstop in buggy at 3
dbstatus
Breakpoints for buggy are on lines  2, 3.

Remove the breakpoint at line 3 and call dbstatus.

dbclear in buggy at 3
dbstatus
Breakpoint for buggy is on line 2.

Clear Error Breakpoints

Set and clear an error breakpoint.

Create a file, buggy.m, that requires an input vector.

function z = buggy(x)
n = length(x);
z = (1:n)./x;

Set an error breakpoint, and call buggy with a matrix input instead of a vector.

dbstop if error
buggy(magic(3))

A run-time error occurs, and MATLAB goes into debug mode, pausing at line 3 in buggy.m.

Error using  ./ 
Matrix dimensions must agree.

Error in buggy at 3
z = (1:n)./x; 
3   z = (1:n)./x;

Type dbquit to exit debug mode.

Clear the breakpoint, and call buggy again with a matrix input instead of a vector.

dbclear if error
buggy(magic(3))

A run-time error occurs, and MATLAB stops execution immediately, without going into debug mode.

Error using  ./ 
Matrix dimensions must agree.

Error in buggy (line 3)
z = (1:n)./x;

Related Examples

Input Arguments

collapse all

file — File namestring

File name, specified as a string. The file name can include a partial path, but must be in a folder on the search path, or in the current folder.

Example: myfile.m

If the file name includes the -completenames option, then the file does not need to be on the search path, as long as the file name is a fully qualified name.

Example: c:\Program Files\MATLAB\myfile.m -completenames

In addition, file can include a filemarker (>) to specify the path to a particular local function or to a nested function within the file.

Example: myfile>myfunction

location — Location in fileline number | line number and anonymous function number | local function name

Location in file to clear breakpoint, specified as follows:

  • Line number in file. The default is 1.

  • Line number in file, at the anonymous function number. For example, 1@2 specifies line number 1, at the second anonymous function. The default anonymous function number is 1.

  • Name of a local function in file.

condition — Type of error breakpointerror | caught error | warning | naninf | ...

Type of error breakpoint, specified as follows:

  • error — Run-time error that occurs outside a try/catch block. If you want to clear a breakpoint set for a specific error, specify the message id. For example:

    • dbclear if error clears all breakpoints set with the dbstop if error command, including breakpoints with a specified message id.

    • dbclear if error MATLAB:ls:InputsMustBeStrings clears the error with a message ID of MATLAB:ls:InputsMustBeStrings.

  • caught error — Run-time error that occurs within the try portion of a try/catch block. If you want to clear a breakpoint set for a specific error, specify the message id.

  • warning — Run-time warning occurs. If you want to clear a breakpoint set for a specific error, specify the message id.

    This condition has no effect if you disable warnings with the warning off all command or if you disable warnings for the specified id. For more information about disabling warnings, see warning.

  • naninf — The code returns an infinite value (Inf) or a value that is not a number (NaN) as a result of an operator, function call, or scalar assignment.

Introduced before R2006a

Was this topic helpful?