buggy
at the MATLAB prompt), this
is what happens: buggy.m
.
Sure enough, there is an error: an extra * at the end of the line. MATLAB does not like
extra asterisks hanging around. Note that even though the error does not occur until Line 9,
none of the lines in the buggy.m
script produce any output.
After we edit buggy.m
to remove that extra asterisk at the end of Line 9,
then we run buggy.m
again, with these results:
It looks like there's another bug, but this time MATLAB executed all the statements before this bug and printed out the results. Let's have a look at line 17:
Comment out this line and run buggy.m
again - you'll see that all the bugs are
now fixed!
Take-home lesson: bugs in MATLAB scripts often suppress output entirely, so carefully check your code for errors. Alternatively, you can comment out the buggy line(s) and rerun your code.