This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

dbup

Shift current workspace to workspace of caller in debug mode

Syntax

dbup

Description

example

dbup changes the current workspace and function context to the workspace and function context of the calling function or script in debug mode. Then you can examine the calling MATLAB® function or script to determine what caused the arguments to be passed to the called function.

Each dbup command changes the workspace and function context to an earlier calling function or script on the stack until the base workspace and function context is reached. You do not need to return to the line at which MATLAB is paused to continue execution or to step to the next line.

Examples

collapse all

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

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

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

Set a breakpoint at myfunction and run myfile with an input of 1. MATLAB pauses in the function myfunction, at the line z = 2 / y. Call whos to view the variables in the current workspace.

dbstop in myfile>myfunction
myfile(1);
whos
Name      Size            Bytes  Class     Attributes

  y         1x1                 8  double    

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

Run the dbup command to switch to the workspace of the calling function, myfile. Then, call whos.

dbup
whos
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.

Tips

  • If you receive an error message such as the following, it means that the parent workspace is under construction so that the value of x is unavailable:

    ??? Reference to a called function result under construction x

Introduced before R2006a