MATLAB Assignments
You can find MATLAB in campus labs, or purchase a student
version (probably worth it). There is a little information
about using MATLAB in the study guide and there is more in
the links, for example to Professor Cooper's book.
On a unix machine, start the MATLAB program by typing
matlab at the command prompt. (You might have to type
tap matlab first.) On PCs, click the appropriate icon;
MATLAB will give you its command prompt which looks like
>>
The easiest and cleanest way to use and report MATLAB is
to create a file (called a script file in MATLAB) which
then can be entered into MATLAB as a single program.
This is the way I want you to do it.
For example, create a file p1.m (there must be a suffix ".m")
for your first problem set, with whatever text editor you
like to use. You can copy the text of Problem Set 1 below to
get started. The lines in p1.m beginning with % are not seen
by MATLAB; they exist to explain what is being done and
for you to add comments. There should be enough comment
and explanation that a reader can understand what you are doing.
The file p1.m should be in the same directory out of which
you are running MATLAB.
Then, you can run all the commands of this file just
by typing the line p1 at the MATLAB command line prompt >> .
If there are errata, you just fix your file and input it
again. It should generally take MATLAB just an instant to
process a correct file.
When you are satisfied with your results, you can create your
output with the following commands
>> diary set1
>> p1
>> diary off
Here, MATLAB will take everything you see as a result of the
p1 command and output it into a file named set1. Of course, you
can choose different names for files. Now, edit the file set1
to include any additional commentary and answers you need.
(For example: don't forget your name!) Then turn in the result
to your TA. Turn in paper output to your TA. To print from a
public machine you will need to set up an account to pay printing
charges.
You can put in some answers, in % comment lines,
as you are working through problems; at the end, then, you
will have no extra editing to do on the diary output.
An exception is with random matrices: they should be different
every time, so you usually need to discuss them after the diary
output.
Follow this convention:
- a line beginning with % exists before the final MATLAB run of
your script file
- do not delete lines seen by MATLAB. We want
to know exactly what MATLAB saw.
- every line you add after the diary production should begin with *
Usually you will find it easiest to put in your answers in % lines
before the diary production. However, for a random matrix, that
may be impossible -- you can't put in an answer and then rerun
the script file, because your answer might not be the same for
the new random matrix.
For the first problem set: you can save time by saving it
into a file p1.m and then edit from there. I've put in the
first few commands to get you started.
There is more information on MATLAB and the campus at the
website of Professor von Petersdorff
www.wam.umd.edu/~petersd/401/
His rules for handing in work are a little different than
mine (our use of MATLAB is different and more modest) --
ignore that part. For PC users, he has particularly helpful
advice on locating m-files at
www.wam.umd.edu/~petersd/401/matlabprob.html
under the heading "m-files".
At least in the beginning: each student must hand in his/her
own MATLAB assignment. You are welcome to help each other
all you like. However, it is CHEATING to directly copy
someone's output, especially as a wholesale file. For
example, if two students hand in homework with the same random
matrices ... they can expect to visit the student honor
council on a cheating charge.