Environmental Engineering Reference
In-Depth Information
Example in MATLAB:
If the inner dimensions of the matrices do not agree an error message results.
Matrix multiplication is a generalization of the multiplication of single numbers.
Clearly, if the product A
B is possible, the product B
A is only possible if A and B
are square matrices. Even then the identity A
B
¼
B
Ais not valid generally (see
exercises below).
The multiplication, described by formula ( 1.6 ), is the standard multiplication of
matrices, denoted by a 0
0 -dot
®
commands. Analogously to the definition of addition, given in ( 1.4 ), there exists
also an element-wise multiplication:
in the formulae and by a * in MATLAB
ð
Þ ij ¼ a ij b ij
A
B
(1.7)
In order to perform this multiplication, matrices A and B need to have the same
number of rows and columns. In formulae element-wise multiplication is denoted
by . * in MATLAB
commands, distinguishing element-wise operation from the
standard matrix multiplication. In formulae we use the '
®
'-dot or omit the operator
symbol entirely. There are scalar multiplication and vector product as further
operations which are explained below.
Division of matrices can be defined for both multiplications. To start with the
simple case: element-wise division is performed with element values.
In
MATLAB
element-wise division is denoted by ./ . Element-wise division with
the same matrix delivers a matrix containing 1 in each entry, which is the unit
matrix with respect to element-wise multiplication.
Example in MATLAB
®
:
®
Obviously, in three entries the element-wise division is performed. In the second
entry of the first row Inf stands for infinity , which is the result of a division by
zero. 12
12 In contrast to school knowledge, division by zero is allowed in MATLAB
. The result is
®
infinity. MATLAB
shows a warning (but no error) in order to remind the user that such an
operation may result in some errors in further operations.
®
Search WWH ::




Custom Search