Show you can save and execute a file. Due before Wednesday's class (9/13)

Get a floppy disk and put "Math 320" and your name on it. This disk will hold your work for the entire semester.

First save the two files junk.m and counter.m on your floppy disk.

The file "junk.m" is a script file that solves a linear algebra problem, Ax=b, in two different ways. Open matlab and execute this file by typing "junk" at the matlab prompt.

When you start matlab, it will be in the wrong directory for your purposes. You saw the error message "Undefined variable or function `junk'." when you typed "junk". If this happens, type "pwd". This will show you what directory you're presently in. Move to the correct directory with the command "cd d:" (to get to the d drive, if that's the name of the floppy disk drive.) In general, "cd .." will move up one level. "cd Math320" will move into the directory Math320 if it's there. To see what's around, type "ls". If you see junk.m and counter.m, then you've arrived.

The file "counter.m" is a file that creates a vector x, which is those integers from a to b. Open matlab and execute this file by typing "[x] = counter(3,50)" at the matlab prompt. (Or whatever numbers you choose.)

Once you have succeeded in doing this, come find me. We will go to the computer room and you will demonstrate the above to me.

Matlab looks for files that end in "*.m". When you create a file for matlab, it must end with .m To execute the file, you type the part of the file name that comes before the .m Your file names can have pretty much anything in them, but only one period. (You can't have a file called "test.this.m".)

You have to be careful in the naming of .m files since there are some names already used by matlab. For example, "rand.m" is a built-in file that creates matrices with random entries. If you create your own file called rand.m then you will never be able to execute it. Whenever you type "rand", you'll get matlab's rand.m To test if your filename is a good one, say "my_dog_fluffy.m", type "help my_dog_fluffy" at the matlab prompt. If matlab has such a file built it, it will tell you about it. (If you type "help rand" it would tell you all about rand and how to use it. It will give you the names of other commands you might be interested in.)

The two files "junk.m" and "counter.m" are of different types:

junk.m is a script file, which is a file that contains a sequence of matlab commands. If you're going to have to type the same 10 commands in a row, but with minor modifications each time, then it's fastest to write a script file, like junk.m, and then use an editor to type those minor modifications in and then rerun junk.m, rather than typing the 10 commands over and over again.

counter.m is a function file. It takes two inputs, the integers a and b, and gives you back a vector, x. Now that you have x, you can do all sorts of things with it.