({{, (RefLink[MatrixForm, paclet:ref/MatrixForm])[list]
prints with the elements of list arranged in a regular array. }})

OpenersNotesSection(Spacer1)Details and Options

In (RefLink[StandardForm, paclet:ref/StandardForm]) the array is shown enclosed in parentheses.

(RefLink[MatrixForm, paclet:ref/MatrixForm]) prints a single-level list in a column. It prints a two-level list in standard matrix form. More deeply nested lists are by default printed with successive dimensions alternating between rows and columns.

Elements in each column are by default centered.

(RefLink[MatrixForm, paclet:ref/MatrixForm]) prints (RefLink[SparseArray, paclet:ref/SparseArray]) objects like the corresponding ordinary lists. »

(RefLink[MatrixForm, paclet:ref/MatrixForm]) takes the same set of options as (RefLink[TableForm, paclet:ref/TableForm]).

(RefLink[MatrixForm, paclet:ref/MatrixForm]) acts as a "wrapper", which affects printing, but not evaluation.

OpenersPrimaryExamplesSection(Spacer1)Examples  (23)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Show the matrix form of a matrix:

MatrixForm[{{1,2},{3,4}}]

Show the matrix form of a (RefLink[SparseArray, paclet:ref/SparseArray]):

MatrixForm[SparseArray[{{1,1}->2},{2,2}]]

Show vector, matrix, and general arrays in matrix form:

MatrixForm[Array[(Subscript[a, ##])&,{2}]]

MatrixForm[Array[(Subscript[a, ##])&,{2,2}]]

MatrixForm[Array[(Subscript[a, ##])&,{2,2,2}]]

MatrixForm[Array[(Subscript[a, ##])&,{2,2,2,2}]]

OpenersExampleSection1(Spacer1)Scope  (3)

Matrices of numbers and formulas:

MatrixForm[RandomReal[5,{3,4}]]

MatrixForm[Table[1/(i+j),{i,4},{j,4}]]

MatrixForm[RotationMatrix[θ,{UnitVector[5,2],UnitVector[5,4]}]]

A matrix of lists:

Outer[List,Range[4],Range[4]]

MatrixForm[%,TableDepth->2]

Use options to control the layout directions:

MatrixForm[{{a,b},{c,d},{e,f}},TableDirections->{Row,Row}]

MatrixForm[{{a,b},{c,d},{e,f}},TableDirections->{Row,Column}]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (2)

Format a (RefLink[SparseArray, paclet:ref/SparseArray]) in matrix form:

SparseArray[RandomInteger[1,{5,5}]]

MatrixForm[%]

Format a (RefLink[StructuredArray, paclet:ref/StructuredArray]) in matrix form:

SymmetrizedArray[i_ :>RandomInteger[5],{5,5},Antisymmetric[{1,2}]]

MatrixForm[%]

OpenersExampleSection3(Spacer1)Options  (6)

OpenersExampleSubsection0(Spacer1)TableAlignments  (2)

Specify the alignment of columns:

MatrixForm[Partition[Range[15]!,3],TableAlignments->Right]

Set alignments for successive dimensions:

m=Partition[Transpose@Partition[Range[18]!,6],3];

MatrixForm[m,TableAlignments->{Right,Top,Center}]

OpenersExampleSubsection1(Spacer1)TableDepth  (1)

By default, all dimensions are formatted:

MatrixForm[{{a,b},{c,d},{e,f}}]

Only use matrix formatting for the outermost dimension:

MatrixForm[{{a,b},{c,d},{e,f}},TableDepth->1]

OpenersExampleSubsection2(Spacer1)TableDirections  (1)

By default, the outermost dimension is a column:

MatrixForm[{{a,b},{c,d},{e,f}}]

Format the first dimension as a row instead:

MatrixForm[{{a,b},{c,d},{e,f}},TableDirections->Row]

OpenersExampleSubsection3(Spacer1)TableHeadings  (1)

Specify headings for rows:

MatrixForm[{{a,b},{c,d},{e,f}},TableHeadings->{{"r1","r2","r3"},None}]

Specify headings for columns:

MatrixForm[{{a,b},{c,d},{e,f}},TableHeadings->{None,{"c1","c2"}}]

Specify headings for rows and columns:

MatrixForm[{{a,b},{c,d},{e,f}},TableHeadings->{{"r1","r2","r3"},{"c1","c2"}}]

OpenersExampleSubsection4(Spacer1)TableSpacing  (1)

The default automatic spacing:

MatrixForm[{{a,b},{c,d},{e,f}}]

Explicitly specify the spacing between rows and between columns:

MatrixForm[{{a,b},{c,d},{e,f}},TableSpacing->{5,2}]

OpenersExampleSection4(Spacer1)Applications  (4)

Display special matrices with matrix formatting:

MatrixForm/@Table[RotationMatrix[θ,UnitVector[3,i]],{i,3}]

MatrixForm/@Table[DiagonalMatrix[Range[4-i],i],{i,0,3}]

Matrices from a matrix decomposition:

MatrixForm/@JordanDecomposition[{{29,1,-21},{3,15,-3},{4,4,4}}]

Formula for a matrix multiplication:

A=Array[(Subscript[a, ##])&,{3,2}];
B=Array[(Subscript[b, ##])&,{2,2}];

MatrixForm[A].MatrixForm[B]==MatrixForm[A.B,TableSpacing->{1,2}]

Display a block matrix as a matrix of matrices:

t=Partition[Map[{{(Subscript[#, 11]),(Subscript[#, 12])},{(Subscript[#, 21]),(Subscript[#, 22])}}&,{a,b,c,d}],2]

MatrixForm[t]

The array flattened to a matrix:

MatrixForm[ArrayFlatten[t]]

OpenersExampleSection5(Spacer1)Properties & Relations  (5)

(RefLink[MatrixForm, paclet:ref/MatrixForm]) formats arrays using standard matrix formatting:

m={{a,b,c},{d,e,f}};

MatrixForm[m]

(RefLink[TableForm, paclet:ref/TableForm]) formats arrays in a tabular form:

TableForm[m]

(RefLink[Grid, paclet:ref/Grid]) formats two-dimensional arrays as a grid:

Grid[m]

Use (RefLink[MatrixPlot, paclet:ref/MatrixPlot]) to visualize the structure of large matrices:

b[i_]:=Table[Binomial[n,k],{n,0,i},{k,0,i}]

MatrixForm[b[5]]

MatrixPlot[b[99]]

Use (RefLink[ArrayPlot, paclet:ref/ArrayPlot]) to visualize the structure of large discrete matrices:

b[i_]:=CellularAutomaton[30,{{1},0},i]

MatrixForm[b[5]]

ArrayPlot[b[100]]

Use (RefLink[Style, paclet:ref/Style]) to affect the display of (RefLink[MatrixForm, paclet:ref/MatrixForm]):

b[i_]:=Table[Binomial[n,k],{n,0,i},{k,0,i}]

Style[MatrixForm[b[20]],Tiny]

Style[MatrixForm[b[3]],{Large,Bold,Orange}]

Use any number form such as (RefLink[ScientificForm, paclet:ref/ScientificForm]) or (RefLink[BaseForm, paclet:ref/BaseForm]) to affect the display of numbers:

ScientificForm[MatrixForm[RandomReal[10^5,{4,4}]],3]

PaddedForm[BaseForm[MatrixForm[RandomInteger[{0,127},{4,4}]],2],8,NumberPadding->{"0",""}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[TableForm, paclet:ref/TableForm])  ▪  (RefLink[Grid, paclet:ref/Grid])  ▪  (RefLink[GraphicsGrid, paclet:ref/GraphicsGrid])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Vectors and Matrices, paclet:tutorial/VectorsAndMatrices])}, {▪(RefLinkPlain[Tables and Matrices, paclet:tutorial/TablesAndMatrices])}, {▪(RefLinkPlain[Tensors, paclet:tutorial/Tensors])}, {▪(RefLinkPlain[Formatted Output, paclet:tutorial/FormattedOutput])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Matrices and Linear Algebra, paclet:guide/MatricesAndLinearAlgebra])}, {▪(RefLinkPlain[Tensors, paclet:guide/Tensors])}, {▪(RefLinkPlain[Mathematical Typesetting, paclet:guide/MathematicalTypesetting])}})}})