Matrix Calculations
Multiplying Matrices
Example: To multiply two matrices or to multiply a matrix by a vector, use a period (.) as the matrix multiplication symbol.
Multiplying By a Scalar
Example: To multiply a matrix by a scalar, use the multiplication symbol * (displayed as ).
Extracting Entries
To extract entries from a matrix, use the command M[i, j], where is the name of the matrix, and and are the row and column.
To extract a submatrix, give a range instead for each index.
Example: Extract the 2 x 2 matrix from the bottom left corner of the matrix A.
Tip: Negative indices can be used: -1 selects the last row (or column) entry, -2 selects the second-to-last row (or column) entry, and so on. Thus, you could obtain the same submatrix using A[-2..-1, 1..2].
This selects the submatrix located in the last two rows and first two columns of A.
To extract entries from a vector, use the command V[i], where i is a number or a range.
|