HMC Math 73: Linear Algebra (Spring, 1999)
Help and hints with MATLAB for HW#4
(M-Files and matrix generation commands)

Here's some MATLAB info that should make this week's assignment go more quickly...

(i) As noted in the assignment, either of "inv(A)" or "A^(-1)" can be used get the inverse of a non-singular matrix A. These both seem to me to be preferable to the book's rather laborious approach of "rref([A eye(size(A))])" (though you should understand the notation and usage of what the book is doing here).

(ii) MATLAB m-files: MATLAB has a built-in programming language that functions via m-files. Any collection of MATLAB commands may be stored in a text file with a .m extension, and typing the filename at the MATLAB command propt causes all commands in the m-file to execute. This allows you to automate tasks and write elaborate programs. You can also use it to define your own MATLAB functions. For this homework, I've created an m-file (hw4.m) that contains the four matrices used in problem 4A. Rather than entering these four matrices yourself, all you need to do is download hw4.m into your MATLAB working directory, then type "hw4" at the MATLAB command prompt. This will put the matrices A, B, C and D into MATLAB's current memory. For more information on m-files, type "help script".

Note: The above information on using m-files is based on my running MATLAB from within my home directory in my UNIX account. Usage may vary based on machine and operating system. In particular, if you are running MATLAB from a working directory that you don't have write permission for, this could be a serious problem. For this assignment, you can probably just copy-and-paste the matrices directly into MATLAB. However, you will eventually be required to create your own m-files for future assignments, so take this oportunity to try to find a MATLAB environment where you can use them. I'll try to talk to the CS people and find out where a good place for this is. In the mean time, your classmates might be your best resource for working out system-specific problems.

(iii) Matrix generation commands: For problem 4B, you'll need to generate a large matrix manually (figuring out exactly what that matrix is is part of the assignment). However, there are faster ways to generate this matrix than just entering one entry at a time. The follwing sequence of commands generates the 6x6 transition matrix used for our $31 example in class, and can, with only slight modification, generate the needed matrix for this problem....