Previous Up Next

2.42.16  Extract a sub-matrix of a matrix (TI compatibility) : subMat

subMat takes 5 arguments : a matrix A, and 4 integers nl1,nc1,nl2,nc2, where nl1 is the index of the first row, nc1 is the index of the first column, nl2 is the index of the last row and nc2 is the index of the last column.
subMat(A,nl1,nc1,nl2,nc2) extract the sub-matrix of the matrix A with first element A[nl1,nc1] and last element A[nl2,nc2].
Define the matrix A :

A:=[[3,4,5],[1,2,6]]

Input :

subMat(A,0,1,1,2)

Output :

[[4,5],[2,6]]

Input :

subMat(A,0,1,1,1]

Output :

[[4],[2]]

By default nl1=0, nc1=0, nl2=nrows(A)-1 and nc2=ncols(A)-1
Input :

subMat(A,1)

Or :

subMat(A,1,0)

Or :

subMat(A,1,0,1)

Or :

subMat(A,1,0,1,2)

Output :

[[1,2,6]]

Previous Up Next