# How To Do 2.670 Matlab Problem Sets

Your problem set solutions need to be turned in as a set of Matlab
scripts. A Matlab script is just a list of commands that Matlab will
run in order, and it's an ordinary text file.
You should be running Matlab to do the problem sets:

athena% add matlab
athena% attach 2.670
athena% matlab /mit/2.670/Computers/Matlab/Examples &

You should also be using emacs to write up your solution scripts:

athena% emacs ~/matlab/solution1.m &

The command above will open an emacs where you can edit a file called
solution1.m. The .m in the file name is required, that is
how matlab knows that the file contains matlab commands. Both you and
the graders can run your script just by typing the name of the file
(without the .m) at the matlab prompt, it will run each of those
commands in order.

All of the problem descriptions are just scripts too. To run an
assignment script (to read what your assignment is), just type

>> Prob1

at the matlab prompt. It will describe that problem in the
assignment. Then, use matlab to try solving the problem at your
matlab prompt. If you need help, try typing "help commandname" if you
already know the name of a command, or "lookfor keywordname" if you
know what you're trying to do but not what command does it. When you
get something that works for the problem solution, put that command in
the .m file you have in emacs.

When you want to say something in the homework you turn in that isn't
a matlab command (your name, or an explanation of why you used a
particular command), you can put a percent sign at the beginning of
that line, ie

% Abbe Cohen
% Problem 13
% Part A: Make a matrix A with values from 1 to 10.
A = [1:10];

### You are required to put in comments at the beginning of each
problem you turn in with your name and the problem number, as above.
Also, put "echo on" at the very start of your file and "echo off" at
the very end of your file, so that all of the commands will be printed
out when we run your script.

When you're done with the file for a problem, you can save it in
emacs by typing Control-X Control-S. You can exit emacs by typing
Control-X Control-C. (For more info on emacs, pick up an emacs quick
reference card from the Athena Consultant's office across from the
fishbowl or from SIPB outside the student center cluster. You can do
more with emacs than just edit one file at a time, by far. But this
is all you need to edit one file at a time.)
Then, to turn in that problem, you can type

turnin -c 2.670 N ~/matlab/filename.m

N is the problem number (1 for Prob1, 2 for Prob2, etc, and 2670
for the Stirling Engine Problem), and filename.m is the file you saved
your solutions in.