Desktop Tools and Development Environment |
Completing the Example
To correct the problem in the example, do the following:
collatzplot.m
line 12, change the string plot_seq
to seq_length(N)
and save the file.
collatzplot.m
. One way to do this is by typing
n
= 1, 2 when n
= 2, and 8 when n
= 3, as expected.
m
, such as 6, to be sure the results are still accurate. To make it easier to verify collatzplot
for m
= 6 as well as the results for collatz
, add this line at the end of collatz.m
collatzplot
for a small value of m
. Now that you know it works correctly, run collatzplot
for a larger value to produce more interesting results. Before doing so, you might want to suppress output for the line you just added in step 6, line 19 of collatz.m
, by adding a semicolon to the end of the line so it appears as
Correcting an M-File | Running Sections in M-Files That Have Unsaved Changes |
© 1994-2005 The MathWorks, Inc.