
6 Editing and Debugging M-Files
• The function displayed in the Stack field o n the toolbar changes to
reflect the current function (sometimes referred to as the caller or calling
workspace). The call stack includes subfunctions as well as called functions.
If you use debugging f unctions from the Command Window, use
dbstack to
view the current call stack.
• If the file you are running is not in the current directory or a directory on
the search path, you are prompted to either add the directory to the path or
change the current directory.
In debug mode, you can set breakpoints, step through programs, examine
variables, and run other functions.
Note that MATLAB could become nonresponsive if it stops at a breakpoint
while displaying a modal dialog box or figure that your M-file creates. In that
event, use Ctrl+C to go the MATLAB prompt.
SteppingThroughanM-File
While debugging, you can s tep through an M-file, pausing at points where
you want to examine values.
Use the step buttons or the step items in the Debug menu of the
Editor/Debugger or desktop, or use the equivalent functions.
Toolbar
Button
Debug Menu
Item Description
Function
Alternative
Continue or Run
or Save and Run
Continue execution of M-file
until completion or until another
breakpoint is encountered. The
menu item says Run or Save and
Run if a file is not already running.
dbcont
None
Go Until Cursor Continue execution of M-file
until the line where the cursor is
positioned. Also available on the
context menu.
None
6-112
Comentarios a estos manuales