This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Diagonal

Diagonal[m]
gives the list of elements on the leading diagonal of the matrix m.
Diagonal
gives the elements on the k^(th) diagonal of m.
  • Diagonal[m] works even if m is not a square matrix.
  • For positive k, Diagonal gives diagonals above the leading diagonal. Diagonal gives diagonals below.
Give the diagonal elements of a matrix:
Give diagonals one element above and below the leading diagonal:
Give a diagonal of a nonsquare matrix:
Give the diagonal elements of a matrix:
In[1]:=
Click for copyable input
Out[1]=
 
Give diagonals one element above and below the leading diagonal:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
 
Give a diagonal of a nonsquare matrix:
In[1]:=
Click for copyable input
Out[1]=
Subdiagonals and superdiagonals:
New in 6