Help and hints with MATLAB for HW#4

(M-Files and matrix generation commands)

**(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".

**(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....

p=.495 v=(1-p)*ones(5,1) A=diag(v,-1) A(1,1:5)=p*ones(1,5) A(6,6)=1