Page 34 - Numerical Analysis Using MATLAB and Excel
P. 34
Multiplication, Division and Exponentiation
vector to be a column vector, not a row vector. It recognizes that is a row vector, and
B
B
warns us that we cannot perform this multiplication using the matrix multiplication operator
(*). Accordingly, we must perform this type of multiplication with a different operator. This
operator is defined below.
2. Element−by−Element Multiplication (multiplication of a row vector by another row vector)
Let
C = [ c c c … c ] 1 2 3 n
and
D = [ d d d … d ] 1 2 3 n
be two row vectors. Here, multiplication of the row vector C by the row vector D is per-
formed with the dot multiplication operator (.*). There is no space between the dot and the
multiplication symbol. Thus,
C.∗ D = [ c d c d c d … c d ] 1 1 2 2 3 3 n n (B.16)
This product is another row vector with the same number of elements, as the elements of C
and .
D
As an example, let
C = [ 1 2 3 4 5 ]
and
D = – [ 2 6 3 8 7 ]
–
Dot multiplication of these two row vectors produce the following result.
C.∗ D = 1 × – ( 2 ) 2 × 6 3 × – ( 3 ) 4 × 8 5 × 7 = – 2 12 9 32 35
–
Check with MATLAB:
C=[1 2 3 4 5]; % Vectors C and D must have
D=[−2 6 −3 8 7]; % same number of elements
C.*D % We observe that this is a dot multiplication
ans =
-2 12 -9 32 35
Similarly, the division (/) and exponentiation (^) operators, are used for matrix division and
exponentiation, whereas dot division (./) and dot exponentiation (.^) are used for element−
by−element division and exponentiation, as illustrated with the examples above.
We must remember that no space is allowed between the dot (.) and the multiplication (*),
division ( /), and exponentiation (^) operators.
Note: A dot (.) is never required with the plus (+) and minus (−) operators.
Numerical Analysis Using MATLAB® and Excel®, Third Edition 1−21
Copyright © Orchard Publications