Page 121 - Numerical Analysis Using MATLAB and Excel
P. 121

Matrix Operations



               ans =
                    3     5     3
                   -1     3     9


               A−B                                            % Subtract B from A
               ans =
                   -1    -1     3
                    1    -1    -1

               If   is any scalar (a positive or negative number), and not [ ] which is a 1 × 1  matrix, then mul-
                  k
                                                                        k
               tiplication of a matrix   by the scalar  , is the multiplication of every element of   by  . k
                                                    k
                                                                                              A
                                     A
               Example 4.2
               Multiply the matrix

                                                                –
                                                        A =   12
                                                              23

               by (a) k =  5  and (b) k =  – 3 +  j2
                       1
                                      2
               Solution:
               a.

                                                    –
                                     k ⋅  A =  5 ×  12  =   5 ×  1 5 ×  – (  2 )  =  5 – 10
                                      1
                                                  23        5 ×  2  5 ×  3     10 15

               b.
                                                                         )
                                                           )
                                           –
                     k ⋅  A =  – (  3 +  j2 ×  12  =  – (  3 +  j2 ×  1 (  –  3 +  j2 ×  – (  2 )  =  –  3 +  j2  6 –  j4
                                     )
                      2
                                                                          )
                                                           )
                                         23         – (  3 +  j2 ×  2  – (  3 + j2 ×  3  –  6 +  j4  – 9 + j6
               Check with MATLAB:
               k1=5; k2=(−3 + 2*j);                % Define scalars k  and k
                                                                     1      2
               A=[1 −2; 2  3];                    % Define matrix A
               k1*A                                % Multiply matrix A by constant k
                                                                                   1
               ans =
                    5   -10
                   10    15
               k2*A                                %Multiply matrix A by constant k
                                                                                  2


               Numerical Analysis Using MATLAB® and Excel®, Third Edition                               4−3
               Copyright © Orchard Publications
   116   117   118   119   120   121   122   123   124   125   126