As you read this
material we strongly recommend that you activate your MATLAB window and try
the commands right there and then
In this section we will
summarize the various operations we can perform on arrays, using MATLAB. These operations give a certain mathematical
character to the arrays, thus enabling us to define several complex engineering
problems in terms of arrays ( matrices and vectors). The operations of matrix multiplication and inner product will be
discussed later in unit 9.
Scalar product ( and division):
Suppose that we have a 2X3 array defined by
flow= [ |
34.78 |
56.01 |
12.3 |
|
45.7 |
12.5 |
34.9 ] |
If we write bigFlow = 5.6
* flow then the array bigFlow is again of size 2X3 but each element
of it is 5.6 times the corresponding element of flow. A similar result is obtained when we write smFlow = flow / 2.5 . Each element of smFlow will be equal to the
corresponding element of flow divided with 2.5.
These operations are shown
in the picture below:
Transposition Operation:
This operation, activated in
MATLAB by the prime symbol ‘ , changes an array by transforming its rows into
columns and its columns into rows. The
prime symbol is also used in mathematical expressions of transposed arrays,
however a superposed T is more common indicator of the transposition operation. For example we can write upper = lower T or upper = lower ’ . Several examples of the transposition operation are given in the
picture below:
Arithmetic addition (and
subtraction):
These operations can be
performed only on two arrays that happen to be of the same size. The result of the operation is another array
of the same size. The elements of the resulting array are equal to the sum ( or
difference) of the elements of the two arrays.
Examples are shown in the picture below:
Notice that if we attempt to
add or subtract two arrays of different size, we get an error message.
Element by element array
operations:
In addition to the
operations described above, MATLAB has the capability of three operations . * and . / and .^ . These
operations are performed element by element.
The . * and . / operations must be performed among arrays of equal
size and the element by element exponentiation can be performed on any size
array. Examples are shown in the
picture below.