** Next:** 3.2.3 Array-array operations
** Up:** 3.2 Manipulating matrices and
** Previous:** 3.2.1 Transposing
** Contents**

Each element of an array can be *individually* operated on. For
example we can subtract or add a constant to each element or multiply or
divide each element by a constant factor. The operators for these
``scalar-array'' operations are the normal operations for arithmetic,
`+`

, `-`

, `*`

, and `/`

. For example,

% Scalar-array operations
clear all;
m = [1 0 -1 4
4 5 -6 7
-2 2 2 1]
m + 1 % add 1 to each element
m - 2 % subtract 2 from each element
3*m/2 % multiply each element by 3 and divide by 2

You've actually seen several examples of this already. Go back and take a
look array in the first example of Section 3.1.

Gus Hart
2005-01-28