dbdown
反向 dbup
工作区切换
说明
示例
查看当前工作区和调用函数工作区
使用 dbup
和 dbdown
命令可查看函数的当前工作区和调用函数工作区。
创建文件 myfile.m
,其中包含以下语句。
function n = myfile(x) n = myfunc(x-1); function z = myfunc(y) z = 2/y;
在 myfunc
处设置一个断点,并通过输入 1
来运行 myfile
。MATLAB 将在运行函数 myfunc
时在第 z = 2/y
行暂停。
dbstop in myfile>myfunc myfile(1);
5 z = 2/y;
调用 whos
以查看当前工作区中的变量。
whos
Name Size Bytes Class Attributes y 1x1 8 double
工作区包含变量 y
,它位于 myfunc
的工作区上下文中。
运行 dbup
命令,以切换到调用函数 myfile
的工作区。调用 whos
,以查看新工作区中的变量。
dbup whos
In workspace belonging to myfile (line 2) Name Size Bytes Class Attributes x 1x1 8 double
工作区包含变量 x
,它位于 myfile
的工作区上下文中。
运行 dbdown
命令,然后调用 whos
。
dbdown whos
In workspace belonging to myfile>myfunc (line 5) Name Size Bytes Class Attributes y 1x1 8 double
工作区再次包含变量 y
,它位于 myfunc
的工作区上下文中。
一步下移多个级别
使用 dbup
和 dbdown
命令,只需一个步骤,即可将当前工作区和函数上下文更改为堆栈上的任何工作区和函数上下文。
创建文件 myfile.m
,其中包含以下语句。
function n = myfile(x) n = myfunc1(x-1); function m = myfunc1(y) m = myfunc2(2/y); function p = myfunc2(z) p = (z-1)/3;
在 myfunc2
处设置一个断点,并通过输入 1
来运行 myfile
。MATLAB 将在运行函数 myfunc2
时在第 p = (z-1)/3
行暂停。
dbstop in myfile>myfunc2 myfile(1);
8 p = (z-1)/3;
调用 whos
以查看当前工作区中的变量。
whos
Name Size Bytes Class Attributes z 1x1 8 double
工作区包含变量 z
,它位于 myfunc2
的工作区上下文中。
运行 dbup
命令切换到基础工作区。调用 whos
,以查看新工作区中的变量。
dbup 2
whos
In workspace belonging to myfile (line 2) Name Size Bytes Class Attributes x 1x1 8 double
工作区包含变量 x
,它位于 myfile
的工作区上下文中。
运行 dbdown
命令,一步切换到 myfunc2
的工作区,然后调用 whos
。
dbdown 2
whos
In workspace belonging to myfile>myfunc2 (line 8) Name Size Bytes Class Attributes z 1x1 8 double
工作区再次包含变量 z
,它位于 myfunc2
的工作区上下文中。
输入参数
n
— 要在调用堆栈上移动的级别数
正整数标量
要在调用堆栈上移动的级别数,指定为正整数标量。
版本历史记录
在 R2006a 之前推出
MATLAB 命令
您点击的链接对应于以下 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:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)