dbstep - Execute next executable line from current breakpoint - MATLAB (original) (raw)

Main Content

Execute next executable line from current breakpoint

Syntax

Description

dbstep executes the next executable line of the current file during debugging, skipping any breakpoints set in functions called by the current line.

example

dbstep in steps to the next executable line. If that line contains a call to another MATLABĀ® code file function, then execution steps to the first executable line of the called function. If no call exists to a MATLAB code file on that line, dbstep in is the same asdbstep.

example

dbstep out runs the rest of the current function and pauses just after leaving the function. MATLAB pauses execution at any breakpoint it encounters.

example

dbstep [nlines](#f4-453072-nlines) executes the specified number of executable lines. MATLAB pauses execution at any breakpoint it encounters.

example

Examples

collapse all

Use dbstep to step over a called local function.

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 the first line in myfile and run myfile with an input of 1. MATLAB pauses in the function myfile, at the line n = myfunction(x-1).

dbstop in myfile myfile(2);

Step to the next execution line. MATLAB reaches the end of the function myfile.

Step once more to complete the execution of myfile and end debugging.

Use dbstep to step through a called local function.

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 the first line in myfile and runmyfile with an input of 2. MATLAB pauses in the function myfile, at the linen = myfunction(x-1).

dbstop in myfile myfile(2);

Step into myfunction. MATLAB enters myfunction and pauses at the first line in the function.

Step through the next four lines of code, completing the execution of myfile and ending debugging.

Use dbstep to step into and out of a called local function.

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 the first line in myfile and runmyfile with an input of 2. MATLAB pauses in the function myfile, at the linen = myfunction(x-1).

dbstop in myfile myfile(2);

Step into myfunction. MATLAB enters myfunction and pauses at the first line in the function.

Step out of myfunction. MATLAB finishes executing myfunction and returns to the calling function myfile.

Step out one more time to complete the execution of myfile and end debugging.

Input Arguments

collapse all

Number of executable lines to execute, specified as a positive integer.

Version History

Introduced before R2006a