Page 32 - Basics of MATLAB and Beyond
P. 32

v  =
                                    1
                                    1
                                    2
                                    2
                               >> v*u
                               ans  =
                                    1     2      0     1
                                    1     2      0     1
                                    2     4      0     2
                                    2     4      0     2
                               >> u*v
                               ans  =
                                    5
                               The matrix inverse can be found with the inv command:

                               >> a = pascal(3)
                               a  =
                                    1     1      1
                                    1     2      3
                                    1     3      6
                               >> inv(a)
                               ans  =
                                    3    -3      1
                                   -3     5     -2
                                    1    -2      1
                               >> a*inv(a)
                               ans  =
                                    1     0      0
                                    0     1      0
                                    0     0      1
                               To multiply the elements of two matrices use the .* operator:

                               >>a=[12;3 4]
                               a  =
                                    1     2
                                    3     4
                               >>b=[23;0 1]
                               b  =
                                    2     3
                                    0     1
                               >> a.*b
                               ans  =
                                    2     6
                                    0     4



                               c   2000 by CRC Press LLC
   27   28   29   30   31   32   33   34   35   36   37