
6 Editing and Debugging M-Files
calling function, which automatically runs the rest of the called function and
returns to the next line in the calling function. To step out, u se the Step Out
button or type
dbstep out in the Command Window.
In
collatzplot, step again to advance to line 11, then line 12. The variable
seq_length in line 11 is a vector with the elements
12
which is correct.
Finally, step again to advance to line 13. Examining the values in line 12,
N = 2 as expected, but the second variable, plot_seq, has two values, where
only one value is ex pected. While the value for
plot_seq is as expected
21
it is the incorrect variab le for plotting. Instead, seq_length(N) should be
plotted.
Correcting Problems and Ending Debugging
Thesearesomeofthewaystocorrectproblemsandendthedebuggingsession:
• “Changing Values and Checking Results” on page 6-118
• “Ending Debugging” on page 6-119
• “Disablin g and Clearin g Break points” on page 6-119
• “Saving Breakpoints” on page 6-121
• “C orrecting an M-File” on page 6-121
• “Completing the Example” on page 6-121
• “Running Sections in M-Files That H ave U nsaved Changes” on page 6-125
Many of these features are used in “Completing the Example” on page 6-121.
Changing Values and Checking Results
While debugging, you can change the value of a variable in the current
workspacetoseeifthenewvalueproducesexpectedresults. Whilethe
6-118
Commentaires sur ces manuels