   ### 5.45.12  Extracting element(s) of a matrix : [] at

Recall that a matrix is a list of lists with the same size.
Input :

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

Output :

[[3,4,5],[1,2,6]]

The prefixed function at or the index notation [...] is used to access to an element or a row or a column of a matrix:

• To extract an element, put the matrix and then, between square brackets put its row index, a comma, and its column index. In Xcas mode the first index is 0, in other modes the first index is 1.
Input :
[[3,4,5],[1,2,6]][0,1]
or :
A[0,1]
or :
A
or :
at(A,[0,1])
Output :
4
• To extract a row of the matrix A, put the matrix and then, between square brackets put the row index, input :
[[3,4,5],[1,2,6]]
or :
A
or :
at(A,0)
Output :
[3,4,2]
• To extract a part of a row, put two arguments between the square brackets : the row index and an interval to designate the selected columns.
Input :
A[1,0..2]
Output :
[1,2,6]
Input :
A[1,1..2]
Output :
[2,6]
• To extract a column of the matrix A, first transpose A (transpose(A)) then extract the row like above.
Input :
tran(A)
or :
at(tran(A),1)
Output :
[4,2]
• To extract a part of a column of the matrix A as a list, put two arguments between the square brackets : an index interval to designate the selected rows and the column index.
Input :
A[0..0,1]
Output :


This may be used to extract a full column, by specifying all the rows as an index interval.
Input :

A[0..1,1]

Output :

[4,2]
• To extract a sub-matrix of a matrix, put between the square brackets two intervals : one interval for the selected rows and one interval for the selected columns.
To define the matrix A, input :
A:=[[3,4,5],[1,2,6]]
Input :
A[0..1,1..2]
Output :
[[4,5],[2,6]]
Input :
A[0..1,1..1]
Output :
[,]
Remark If the second interval is omitted, the sub-matrix is made with the consecutive rows given by the first interval.
Input :
A[1..1]
Output :
[[1,2,6]]

You may also assign an element of a matrix using index notation, if you assign with := a new copy of the matrix is created and the element is modified, if you assign with =<, the matrix is modified in place.   