DiagonalMatrix

DiagonalMatrix[list]
gives a matrix with the elements of list on the leading diagonal, and elsewhere.

DiagonalMatrix[list, k]
gives a matrix with the elements of list on the k^(th) diagonal.

DiagonalMatrix[list, k, n]
pads with s to create an n×n matrix.

DetailsDetails

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

Construct a diagonal matrix:

In[1]:=
Click for copyable input
Out[1]//MatrixForm=

A superdiagonal matrix:

In[2]:=
Click for copyable input
Out[2]//MatrixForm=

A subdiagonal matrix:

In[3]:=
Click for copyable input
Out[3]//MatrixForm=
New in 1 | Last modified in 7
New to Mathematica? Find your learning path »
Have a question? Ask support »