Page 35 - MATLAB an introduction with applications
P. 35

20 ———  MATLAB: An Introduction with Applications

                   Example E1.1: Consider the two matrices:

                                      1  0    1          7  4   2
                                                          
                                              
                                     
                                 A =  2   3  4      and     B = 3  5  6  
                                                          
                                     
                                              
                                     −1  6    7        −1  2   1 
                                                          
                                     
                   Using MATLAB, determine the following:
                        (a)  A + B
                        (b)  AB
                        (c)  A 2
                        (d) A T
                        (e)  B –1
                             T T
                        (f )  B A
                             2
                                 2
                        (g)  A  + B  – AB
                        (h)  determinant of A, determinant of B and determinant of AB.
                   Solution:
                            >> A = [1 0 1; 2 3 4; –1 6 7]
                            A =
                                1   0     1
                                2   3     4
                               –1   6     7
                            >> B = [7 4 2; 3 5 6; –1 2 1]
                            B =
                                7   4     2
                                3   5     6
                               –1   2     1

                   (a) >> C = A + B
                            C =
                                8   4     3
                                5   8    10
                               –2   8     8

                   (b) >> D = A*B
                            D =
                               6    6     3
                              19   31    26
                               4   40    41
                   (c)  >> E = A^2 = A  2
                            E =
                              0     6     8
                              4    33    42
                              4    60    72








                   F:\Final Book\Sanjay\IIIrd Printout\Dt. 10-03-09
   30   31   32   33   34   35   36   37   38   39   40