The following matrix operations are available in MATLAB:
These matrix operations apply to scalars (1-by-1 matrices) as well. If the sizes of the matrices are incompatible for the matrix operation, an error message will be generated, except in the case of scalar-matrix operations (for addition, subtraction, multiplication and division) in which case each entry of the matrix is operated on by the scalar.
The "matrix division" operations deserve special comment. If *x = A\b*is the solution of*A*x = b**x = b/A*is the solution of*x*A = b*
A is square, then it is factored using
Gaussian elimination and these factors are used to solve A*x =
b. If A is not square, it is factored using Householder
orthogonalization with column pivoting and the factors are used to solve
the under- or over- determined system in the least squares sense. Right
division is defined in terms of left division by b/A =
(A'\b').
The matrix operations of addition and subtraction already operate
entry-wise but the other matrix operations given above do not, they are
[1,2,3,4] .* [1,2,3,4]or [1,2,3,4] .^ 2will yield [1,4,9,16]. Try it! This is particularly useful when using MATLAB graphics. |