| Mathematics | ![]() |
Addition and Subtraction
Addition and subtraction of matrices is defined just as it is for arrays, element-by-element. Adding A to B and then subtracting A from the result recovers B.
X = A + B
X =
9 2 7
4 7 10
5 12 8
Y = X -A
Y =
8 1 6
3 5 7
4 9 2
Addition and subtraction require both matrices to have the same dimension, or one of them be a scalar. If the dimensions are incompatible, an error results.
X = A + C
Error using ==> +
Matrix dimensions must agree.
w = v + s
w =
9 7 6
| Creation | Vector Products and Transpose | ![]() |