This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Lists and Matrices / List Construction  /
DiagonalMatrix

  • DiagonalMatrix[ list ] gives a matrix with the elements of list on the leading diagonal, and 0 elsewhere.
  • See the Mathematica book: Section 1.8.3Section 3.7.1.
  • See also: IdentityMatrix.
  • Related package: LinearAlgebra`MatrixManipulation`.

    Further Examples

    In[1]:=

    Out[1]=

    This displays the result in traditional matrix form, instead of as a list of lists.

    In[2]:=

    Out[2]//MatrixForm=