帮助中心帮助中心
从当前断点执行下一个可执行代码行
dbstep
dbstep in
dbstep out
dbstep nlines
示例
dbstep 在调试过程中执行当前文件中的下一可执行代码行,跳过在当前行所调用的函数中设置的任何断点。
dbstep in 跳转至下一可执行代码行。如果该行包含对另一个 MATLAB® 代码文件函数的调用,执行将步进到所调用函数的第一个可执行代码行。如果该行不存在对 MATLAB 代码文件的调用,则 dbstep in 与 dbstep 相同。
dbstep out 将运行当前函数的其余代码并在退出函数后立即暂停。MATLAB 将在它遇到的任何断点处暂停执行。
dbstep nlines 将执行指定的可执行代码行数。MATLAB 将在它遇到的任何断点处暂停执行。
nlines
全部折叠
使用 dbstep 越过调用的局部函数。
创建文件 myfile.m,其中包含以下语句。
myfile.m
function n = myfile(x) n = myfunction(x-1); function z = myfunction(y) z = 2/y;
在 myfile 的第一行设置一个断点,并通过输入 1 来运行 myfile。MATLAB 将在运行函数 myfile 时在第 n = myfunction(x-1) 行暂停。
myfile
1
n = myfunction(x-1)
dbstop in myfile myfile(2);
2 n = myfunction(x-1);
步入下一可执行代码行。MATLAB 到达函数 myfile 的末尾。
K>> dbstep
End of function myfile.
再步进一次,完成 myfile 的执行并结束调试。
使用 dbstep 步进调用的局部函数。
在 myfile 的第一行设置一个断点,并通过输入 2 来运行 myfile。MATLAB 将在运行函数 myfile 时在第 n = myfunction(x-1) 行暂停。
2
步入 myfunction。MATLAB 将进入 myfunction 并在该函数的第一行暂停。
myfunction
K>> dbstep in
5 z = 2/y;
逐步步进后面的四行代码,完成 myfile 的执行并结束调试。
K>> dbstep 4
ans = 2
使用 dbstep 步入和步出调用的局部函数。
步出 myfunction。MATLAB 将结束执行 myfunction 并返回到调用函数 myfile。
K>> dbstep out
再步出一次,完成 myfile 的执行并结束调试。
要执行的可执行代码行数,指定为正整数。
在 R2006a 之前推出
dbclear | dbcont | dbquit | dbstatus | dbstop
dbclear
dbcont
dbquit
dbstatus
dbstop
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office