MATLAB 帮助中心
删除断点
dbclear all
dbclear in file
dbclear in file at location
dbclear if condition
dbclear all 用于删除所有 MATLAB® 代码文件中的所有断点,以及为错误、捕获的错误、捕获的错误标识符、警告、警告标识符、naninf 和分号未隐藏的输出设置的所有断点。
naninf
dbclear in file 将删除指定文件中的所有断点。in 关键字是可选的。
file
in
示例
dbclear in file at location 将删除在指定文件中的指定位置设置的断点。at 和 in 关键字为可选参数。
location
at
dbclear if condition 将删除使用指定的 condition(例如 dbstop if error 或 dbstop if naninf)设置的所有断点。
condition
dbstop if error
dbstop if naninf
全部折叠
在程序文件中设置断点,然后将其清除。
创建文件 buggy.m,其中包含以下语句。
buggy.m
function z = buggy(x) n = length(x); z = (1:n)/x';
在第 2 行和第 3 行添加断点。使用 dbstatus 列出所有断点。
dbstatus
dbstop in buggy at 2 dbstop in buggy at 3 dbstatus
Breakpoints for buggy are on lines 2, 3.
删除 buggy.m 中的所有断点。调用 dbstatus 以确认清除所有断点。
dbclear in buggy dbstatus
在程序文件中的特定位置设置断点,然后将其清除。
删除第 3 行的断点并调用 dbstatus。
dbclear in buggy at 3 dbstatus
Breakpoint for buggy is on line 2.
设置和清除错误断点。
创建文件 buggy.m,该文件需要一个输入向量。
设置错误断点,并使用矩阵输入(而不是向量)调用 buggy。
buggy
dbstop if error buggy(1:10)
发生运行时错误,MATLAB 进入调试模式,在 buggy.m 中的第 3 行上暂停。
Error using / Matrix dimensions must agree. Error in buggy (line 3) z = (1:n)/x'; ^
调用 dbquit 以退出调试模式。
dbquit
清除断点,然后使用矩阵输入(而不是向量)再次调用 buggy。
dbclear if error buggy(1:10)
发生运行时错误,MATLAB 立即暂停执行,但不进入调试模式。
文件名,指定为字符向量或字符串标量。对于 MATLAB 搜索路径中的文件,文件名可以包含部分路径名称;对于任何文件,文件名都可以包含绝对路径名称。有关 MATLAB 中有效文件名的详细信息,请参阅指定文件名称。
示例: myfile.m
myfile.m
此外,file 可以包括一个文件标记 (>),用来指定到特定局部函数或到文件内的嵌套函数的路径。
>
示例: myfile>myfunction
myfile>myfunction
数据类型: char | string
char
string
要清除的断点在 file 中的位置,指定为如下格式:
file 中的行号,指定为字符向量或字符串标量。默认值为 1。
1
file 中匿名函数编号所在的行号,指定为字符向量或字符串标量。例如,1@2 指定第 1 行中的第 2 个匿名函数。如果未指定匿名函数编号,则默认值为 1。
1@2
file 中的局部函数的名称,指定为字符向量或字符串标量。
error
caught error
warning
...
错误断点的类型,指定为:
error - 在 try/catch 块之外发生的运行时错误。如果要清除为特定错误设置的断点,请指定消息 ID。例如:
try/catch
dbclear if error 将清除使用 dbstop if error 命令设置的所有断点,包括具有指定消息 ID 的断点。
dbclear if error
dbclear if error MATLAB:ls:InputsMustBeStrings 将清除消息 ID 为 MATLAB:ls:InputsMustBeStrings 的错误。
dbclear if error MATLAB:ls:InputsMustBeStrings
MATLAB:ls:InputsMustBeStrings
caught error- 在 try/catch 块的 try 部分发生的运行时错误。如果要清除为特定错误设置的断点,请指定消息 ID。
try
warning - 运行时警告。如果要清除为特定警告设置的断点,请指定消息 ID。
如果您已通过 warning off all 命令禁用警告或者已为指定的消息 ID 禁用警告,则此条件无效。有关禁用警告的详细信息,请参阅 warning。
warning off all
naninf - 非数字值错误或无限值错误。由于运算符、函数调用或标量赋值原因,代码返回无限值 (Inf) 或非数字值 (NaN) 时,将出现这些错误。
Inf
NaN
在 R2024b 中: unsuppressed output - 代码显示取消隐藏的输出,因为该行没有被分号 (;) 隐藏。作为函数调用结果显示的输出(例如来自 disp 或 fprintf 的输出)不会停止执行。
unsuppressed output
;
disp
fprintf
在 R2006a 之前推出
dbquit | dbstack | dbstatus | dbstop | filemarker
dbstack
dbstop
filemarker
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处