Installation guide
6 Editing and Debugging M-Files
only stop at the for statement once. Instead place the breakpoint at the next
line,
m=n+1 to stop at each pass through the loop.
Yo u cannot set breakpoints while MATLAB is busy, for example, running an
M-file, unless that M-file is paused at a breakpoint.
Setting Standard Breakpoints
To set a standard breakpoint using the Editor/Debugg er, click in the
breakpoint alley at the line where you want to set the breakpoint. The
breakpoint alley is the narrow column o n the left side of the Editor/Debugger,
just right o f the line number. Set breakpoints at lines that are preceded by
a - (dash). Lines not preceded by a dash, s uch as comments or blank lines,
are not executable — if you try to set a breakpoint there, it is actually set at
thenextexecutableline. Otherwaystosetabreakpointaretopositionthe
cursor in the line and then click the Set/Clear Breakpoint button
on the
toolbar, or select Set/Clear Breakpoint from the Debug menu or the context
menu. A breakpoint icon appears.
Set Breakpoints for the Example. It is unclear whether the problem in
the example is in
collatzplot or collatz. To start, set breakpoints in
collatzplot.m at lines 10, 11, and 12. The breakpoint at line 10 allows you
to step into
collatz to see if the problem might be there. The breakpoints at
lines 11 and 12 stop the program where you can examine the interim results.
6-108