Documentation

dbstep

Execute next executable line from current breakpoint

Syntax

dbstep
dbstep in
dbstep out
dbstep nlines

Description

example

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

example

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

example

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

example

dbstepnlinesexecutes the specified number of executable lines. MATLAB pauses execution at any breakpoint it encounters.

Examples

collapse all

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

functionn = myfile(x) n = myfunction(x-1);functionz = myfunction(y) z = 2 / y ;

Set a breakpoint at the first line inmyfileand runmyfilewith an input of1. MATLAB pauses in the functionmyfile, at the linen = myfunction(x-1).

dbstopinmyfilemyfile(2);
2 n = myfunction(x-1);

Step to the next execution line. MATLAB reaches the end of the functionmyfile.

K>> dbstep
End of function myfile.

Step once more to complete the execution ofmyfileand end debugging.

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

functionn = myfile(x) n = myfunction(x-1);functionz = myfunction(y) z = 2 / y ;

Set a breakpoint at the first line inmyfileand runmyfilewith an input of1. MATLAB pauses in the functionmyfile, at the linen = myfunction(x-1).

dbstopinmyfilemyfile(2);
2 n = myfunction(x-1);

Step intomyfunction. MATLAB entersmyfunctionand pauses at the first line in the function.

K>> dbstep in
5 z = 2 / y;

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

K>> dbstep 4
ans = 2

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

functionn = myfile(x) n = myfunction(x-1);functionz = myfunction(y) z = 2 / y ;

Set a breakpoint at the first line inmyfileand runmyfilewith an input of1. MATLAB pauses in the functionmyfile, at the linen = myfunction(x-1).

dbstopinmyfilemyfile(2);

Step intomyfunction. MATLAB entersmyfunctionand pauses at the first line in the function.

K>> dbstep in
5 z = 2 / y;

Step out ofmyfunction. MATLAB finishes executingmyfunctionand returns to the calling functionmyfile.

K>> dbstep out
2 n = myfunction(x-1);

Step out one more time to complete the execution ofmyfileand end debugging.

Input Arguments

collapse all

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

Introduced before R2006a

Was this topic helpful?