dbdown - Reverse dbup workspace shift - MATLAB (original) (raw)

Main Content

Reverse dbup workspace shift

Syntax

Description

dbdown changes the current workspace and function context to the workspace and function context of the called MATLABĀ® function or script in debug mode. You must issue the dbup command at least once before you issue this command. dbdown is the opposite of dbup.

Multiple dbdown commands change the workspace and function context to each successively executed MATLAB function or script on the stack until the current workspace and function context is the line at which MATLAB is paused. You do not have to move back to the paused line to continue execution or to step to the next line.

dbdown can only be called from the command line.

example

dbdown [n](#mw%5Fd9864496-1e31-4243-bb88-e01cdb1502b4) changes the current workspace and function context to the workspace and function context of the called function or script that is n levels lower on the stack. Runningdbdown n is equivalent to running thedbdown command n times.

example

Examples

collapse all

Use the dbup and dbdown commands to view the current and calling function workspace of a function.

Create a file myfile.m that contains these statements.

function n = myfile(x) n = myfunc(x-1);

function z = myfunc(y) z = 2/y;

Set a breakpoint at myfunc and runmyfile with an input of 1. MATLAB pauses in the function myfunc, at the linez = 2/y.

dbstop in myfile>myfunc myfile(1);

Call whos to view the variables in the current workspace.

Name Size Bytes Class Attributes

y 1x1 8 double

The workspace contains the variable y, which is in the workspace context for myfunc.

Call dbup from the command line to switch to the workspace of the calling function, myfile. Callwhos to view the variables in the new workspace.

In workspace belonging to myfile (line 2) Name Size Bytes Class Attributes

x 1x1 8 double

The workspace contains the variable x, which is in the workspace context for myfile.

Call dbdown from the command line, and then callwhos.

In workspace belonging to myfile>myfunc (line 5) Name Size Bytes Class Attributes

y 1x1 8 double

The workspace once again contains the variable y, which is in the workspace context for myfunc.

Use the dbup anddbdown commands to change the current workspace and function context to any workspace and function context on the stack with one step.

Create a file myfile.m that contains these statements.

function n = myfile(x) n = myfunc1(x-1);

function m = myfunc1(y) m = myfunc2(2/y);

function p = myfunc2(z) p = (z-1)/3;

Set a breakpoint at myfunc2 and runmyfile with an input of 1. MATLAB pauses in the function myfunc2, at the linep = (z-1)/3.

dbstop in myfile>myfunc2 myfile(1);

Call whos to view the variables in the current workspace.

Name Size Bytes Class Attributes

z 1x1 8 double

The workspace contains the variable z, which is in the workspace context for myfunc2.

Call dbup from the command line to switch to the base workspace. Call whos to view the variables in the new workspace.

In workspace belonging to myfile (line 2) Name Size Bytes Class Attributes

x 1x1 8 double

The workspace contains the variable x, which is in the workspace context for myfile.

Call dbdown from the command line to switch to the workspace of myfunc2 with one step and then callwhos.

In workspace belonging to myfile>myfunc2 (line 8) Name Size Bytes Class Attributes

z 1x1 8 double

The workspace once again contains the variable z, which is in the workspace context for myfunc2.

Input Arguments

collapse all

Number of levels to move on the call stack, specified as a positive integer scalar.

Tips

Version History

Introduced before R2006a