
Vector and Matrices -
Manipulation
We will now look at how we can
manipulate vectors and matrices within programs.
SUB
()
The
SUB
(or the symbol ™) infix operator (displayed
as a subscript)
will subtract an element from a vector or a row from a matrix.
v
SUB r extracts
the rth element of the vector v,
starting from the left hand side. For example,
[a, b, c, d, e] SUB 2 = b
this actually displays as
[a, b, c, d, e]2 = b
v
SUB -r extracts
the rth element from the right hand side of the vector v,
for example
[a,
b, c, d, e]-2 = d
M
SUB r extracts the rth row from the top of the matrix
M
M
SUB -r extracts the rth row from the bottom of the matrix
M.
For example,

M
SUB r SUB c extracts the element in row r and
column c of the matrix
M.
M
SUB r SUB c displays as
Mr,c
M
SUB SUB c extracts
column c from the matrix
M.
M
SUB SUB c displays as
M™™c
The Derive function
ELEMENT(v, r) performs
the same function as
SUB.
ROW
and
COL
The
ROW
infix operator acts in the same way as
SUB,
in that it extracts a row from a matrix or an element from a
vector.
COL
extracts a column from a matrix. For example,
Extracting Sub-Matrices
We can use the infix operators SUB,
ROW
and COL
to extract a sub-matrix of any matrix. For example,

M
SUB [2,3]
extracts rows 2 and 3, which displays as
We can also use ellipsis to extract a
range of rows, for example M[2,
..., 4]
it is very important that you type only
3 dots for the ellipsis.
To extract, say, the bottom right 2x2
sub matrix of matrix M,
we could use
or
M SUB [3,4] SUBSUB[3,4]
which displays as
to extract the bottom right 3x3 matrix,
we could use
More Vectors and Matrices