Page 243 -
P. 243

kl ∑
                                                      (AB ) =    AB  hl                     (8.3)
                                                                   kh
                                                               h
                             This result can be also interpreted by observing that the (k, l) element of the
                             product is the dot product of the k-row of A and the l-column of B.
                              In MATLAB, we denote the product of the matrices A and B by A*B.

                             Example 8.1
                             Write the different routines for performing the matrix multiplication from the
                             different definitions of the matrix product.

                             Solution: Edit and execute the following script M-file:

                                D=[1 2 3; 4 5 6];
                                E=[3 6 9 12; 4 8 12 16; 5 10 15 20];

                                F=D*E

                                F1=zeros(2,4);
                                for i=1:2
                                   for j=1:4
                                     for k=1:3
                                     F1(i,j)=F1(i,j)+D(i,k)*E(k,j);
                                     end
                                   end
                                end
                                F1

                                F2=zeros(2,4);
                                for i=1:2
                                   for j=1:4
                                     F2(i,j)=D(i,:)*E(:,j);
                                   end
                                end
                                F2

                             The result F is the one obtained using the MATLAB built-in matrix multipli-
                             cation; the result F1 is that obtained from Eq. (8.3) and F2 is the answer
                             obtained by performing, for each element of the matrix product, the dot
                             product of the appropriate row from the first matrix with the appropriate col-


                             © 2001 by CRC Press LLC
   238   239   240   241   242   243   244   245   246   247   248