The following matrix operations are available in MATLAB:
+ addition - subtraction * multiplication ^ power ' transpose \ left division / right divisionThese matrix operations apply, of course, to scalars (1-by-1 matrices) as well. If the sizes of the matrices are incompatible for the matrix operation, an error message will result, except in the case of scalar-matrix operations (for addition, subtraction, and division as well as for multiplication) in which case each entry of the matrix is operated on by the scalar.
The ``matrix division'' operations deserve special comment. If A is an invertible square matrix and b is a compatible column, resp. row, vector, then
x=A \ bis the solution of A*x=b and, resp.,
x=b/Ais the solution of x*A=b . In left division, if 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')'Array operations. The matrix operations of addition and subtraction already operate entry-wise but the other matrix operations given above do not-they are matrix operations. It is important to observe that these other operations,
* , ^ , \ , and /,can be made to operate entry-wise by preceding them by a period. For example, either
[1,2,3,4].^2will yield [1,4,9,16]. Try it. This is particularly useful when using Matlab graphics.