To 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:
-0.1667 0.0556 0.1111
0.7083 -0.3194 0.1111
-0.0833 0.1944 -0.1111
Note 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:
[ -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
This defines some matrices. Then suppose you wanted to find
transpose(inv(sym(A))*transpose(D)+B*C) or (inv(sym(A))*D’+B*C)’
and press enter. This gives
[ -427/18, 4421/72, 1007/36]
[ -257/18, -1703/72, 451/36]
In matlab, A’ means AT 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 not to say anything about it. If you don’t do this, then when you press return, it will list the matrices and you don’t want to see that. You just want the answer. When you have done a computation in matlab, you ought to go to >> and type “clear all” and then enter. That way, you can use the symbols again with different definition. If you don’t do the “clear all” thing, it will go on thinking that A is what you defined earlier.