M-files
For most of what we will be doing, using the command window is not efficient.
Your code will consist of dozens of lines.
You should create an M-file, and then run that.
- You can put comments in the file, with a "%" to start the line.
- Put "clc" as the first line of all your programs. This clears the
command window, and anything in it came from this time the program ran.
There is nothing more frustrating 10 minutes "fixing" a problem, only to
realize that you are looking at old error messages and you fixed it 9
minutes ago (or longer).
- You should make a few changes to your code, run, and then proceed only
when you have the code running. If you type in dozens of lines of
code, it can be difficult to track down the root cause of your problem, and
you will spend time on the secondary problems.
- If you do have a problem finding where the error is, comment out (make
the statement a comment) a large of number of lines, and then see if what is
left works. Once you get something running, add lines back (by
un-commenting) a few at a time until the isolate the one causing a problem.
- While debugging, you can run the loop only a few times, and remove the
":" from lines to see what the program is producing. Once you isolate
and fix the problem, change the loop to run the full number of times, and
put the ";" back at the end of each line.
The buttons circled below will execute your code, exactly as if you had cut
and pasted it into the command window. You can do the same thing with F5,
or the "Debug, Run" menus choice.

last revised 2/7/2011