The following matrix operations are available in MATLAB:
+ addition
- subtraction
* multiplication
^ power
' transpose
\ left division
/ right division
These matrix operations apply, of course, to scalars (l-by-l 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 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\b is the solution of A * : = b and, resp.,
= b/A is the solution of :z * A = b.
In left division, if A is square, then it is factored using Gaussian elimination and these factors used to solve A * 2 = b. If A is not square, it is factored using Householder orthogonalization with column pivoting and the factors 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')'.
It is important to observe that the operations *, , \, and / will operate entrywise if they are preceded by a period. For example, either [1,2,3,4].*[1,2,3,4] or [1, 2, 3, 4].^ 2 will yield
[1, 4, 9 ,16]
Click on an item listed below to access additional MATLAB-related hints.
Return to ACS home page.
Please send comments and suggestions to
consult@rpi.edu