| 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
A.*A
the result is an array containing the squares of the integers from 1 to 16, in an unusual order.
ans =
256 9 4 169
25 100 121 64
81 36 49 144
16 225 196 1
Building Tables
Array operations are useful for building tables. Suppose n is the column vector
n = (0:9)';
pows = [n n.^2 2.^n]
builds a table of squares and powers of two.
pows =
0 0 1
1 1 2
2 4 4
3 9 8
4 16 16
5 25 32
6 36 64
7 49 128
8 64 256
9 81 512
The elementary math functions operate on arrays element by element. So
format short g x = (1:0.1:2)'; logs = [x log10(x)]
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
| Linear Algebra | Multivariate Data | ![]() |