Parts of Matrices

Mathematica provides several convenient methods for extracting and manipulating parts of matrices. The flexible (Part) and (Span) syntaxes provide compact yet readable representations of operations on submatrices and matrix elements. Mathematica's symbolic character also allows convenient pattern and rule-based element specifications.

ReferenceReference

Dimensions dimensions of a matrix

MatrixQ test whether an expression is a matrix

Part elements and submatrices: ; resettable with

Take take rows, columns and submatrices

Drop drop rows, columns and submatrices

Diagonal get the list of elements on the diagonal

RotateLeft, RotateRight cyclically rotate rows or columns

Reverse reverse rows or columns

Transpose interchange rows and columns

Join join rows or columns of several matrices

UpperTriangularize ▪ LowerTriangularize

Position find positions where elements that match a pattern occur

Extract extract elements that appear at a list of positions

ReplacePart make replacements for collections of elements

ArrayRules get a list of positions and values for nonzero elements

Map apply a function at any level

New to Mathematica? Find your learning path »
Have a question? Ask support »