|
|
|||
|
|
| Mathematica Tutorial | |Functions » |
| m[[i,j]] | the i, jth entry |
| m[[i]] | the ith row |
| m[[All,i]] | the ith column |
| Take[m,{i0,i1},{j0,j1}] | the submatrix with rows i0 through i1 and columns j0 through j1 |
| m[[i0;;i1,j0;;j1]] | the submatrix with rows i0 through i1 and columns j0 through j1 |
| m[[{i1,...,ir}, {j1, ... , js}]] | the r×s submatrix with elements having row indices ik and column indices jk |
| Tr[m,List] | elements on the diagonal |
| ArrayRules[m] | positions of nonzero elements |
Ways to get pieces of matrices.
|
|
|
|
| m={{a11,a12,...},{a21,a22,...},...} | assign m to be a matrix |
| m[[i,j]]=a | reset element {i, j} to be a |
| m[[i]]=a | reset all elements in row i to be a |
| m[[i]]={a1,a2,...} | reset elements in row i to be {a1, a2, ...} |
| m[[i0;;i1]]={v1,v2,...} | reset rows i0 through i1 to be vectors {v1, v2, ...} |
| m[[All,j]]=a | reset all elements in column j to be a |
| m[[All,j]]={a1,a2,...} | reset elements in column j to be {a1, a2, ...} |
| m[[i0;;i1,j0;;j1]]={{a11,a12,...},{a21,a22,...},...} | reset the submatrix with rows i0 through i1 and columns j0 through j1 to new values |
|
|
|
|
|
|
|
|