Getting Started |
Arrays
When they are taken away from the world of linear algebra, matrices become two-dimensional numeric arrays. Arithmetic operations on arrays are done element-by-element. This means that addition and subtraction are the same for arrays and matrices, but that multiplicative operations are different. MATLAB uses a dot, or decimal point, as part of the notation for multiplicative array operations.
The list of operators includes
+ |
Addition |
- |
Subtraction |
.* |
Element-by-element multiplication |
./ |
Element-by-element division |
.\ |
Element-by-element left division |
.^ |
Element-by-element power |
.' |
Unconjugated array transpose |
If the Dürer magic square is multiplied by itself with array multiplication
the result is an array containing the squares of the integers from 1 to 16, in an unusual order.
Building Tables
Array operations are useful for building tables. Suppose n
is the column vector
builds a table of squares and powers of 2.
The elementary math functions operate on arrays element by element. So
logs = 1.0 0 1.1 0.04139 1.2 0.07918 1.3 0.11394 1.4 0.14613 1.5 0.17609 1.6 0.20412 1.7 0.23045 1.8 0.25527 1.9 0.27875 2.0 0.30103
More About Matrices and Arrays | Multivariate Data |