suivant: Modify an element or monter: Arithmetic and matrix précédent: Hadamard power (infixed version):   Table des matières   Index

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

Recall that a matrix is a list of lists with 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, beetween 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[0][1]
or
at(A,[0,1])
Output :
4

• To extract a row of the matrix A, put the matrix and then, beetween square brackets put the row index, input :
[[3,4,5],[1,2,6]][0]
or
A[0]
or
at(A,0)
Output :
[3,4,2]

• To extract a part of a row, put two arguments beetween the square brackets : the row index and an interval to design 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 tranpose A (transpose(A)) then extract the row like above.
Input :
tran(A)[1]
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 beetween the square brackets : an index interval to design the selected rows and the column index.
Input :
A[0..0,1]
Output :
[4]

This may be used to extract a full column, by specifying all the rows as 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 definie 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 :
[[4],[2]]
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 the 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.

suivant: Modify an element or monter: Arithmetic and matrix précédent: Hadamard power (infixed version):   Table des matières   Index
giac documentation written by Renée De Graeve and Bernard Parisse