8.7. MATLAB AND MATRIX ARITHMETIC 151

What if the right side of 8.19 had been(

0 1 3)T

? What would be the solution to 1 0 11 −1 11 1 −1

 x

yz

=

 013

?

By the above discussion, it is just xyz

=

 0 12

12

1 −1 01 − 1

2 − 12

 0

13

=

 2−1−2

 .

This illustrates why once you have found the inverse of a given matrix, you can use it tosolve many different systems easily.

8.7 MATLAB And Matrix ArithmeticTo find the inverse of a square matrix in matlab, you open it and type the following. The>> will already be there.

>>inv([1,2,3;5,2,7;8,2,1]) Then press enter and it will give the following:ans =-0.1667 0.0556 0.11110.7083 -0.3194 0.1111-0.0833 0.1944 -0.1111Note how it computed the inverse in decimals. If you want the answer in terms of

fractions, you do the following:>>inv(sym([1,2,3;5,2,7;8,2,1])) Then press enter and it will give the following:ans =[ -1/6, 1/18, 1/9][ 17/24, -23/72, 1/9][ -1/12, 7/36, -1/9]You can do other things as well. Say you have>>A=[1,2,3;5,2,7;8,2,1];B=[3,2,-5;3,11,2;-3,-1,5];C=[1,2;4,-3;7,3];D=[1,2,3;-3,2,1];This defines some matrices. Then suppose you wanted to find

(A−1DT +BC

)T. You

would then typetranspose(inv(sym(A))*transpose(D)+B*C) or (inv(sym(A))*D’+B*C)’and press enter. This givesans =[ -427/18, 4421/72, 1007/36][ -257/18, -1703/72, 451/36]In matlab, A’ means ĀT the conjugate transpose of A. Since everything is real here, this

reduces to the transpose.To get to a new line in matlab, you need to press shift enter. Notice how a ; was placed

after the definition of A,B,C,D. This tells matlab that you have defined something but notto say anything about it. If you don’t do this, then when you press return, it will list thematrices and you don’t want to see that. You just want the answer. When you have done