This is documentation for Mathematica 6, 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[m, k]
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[m, k] gives diagonals above the leading diagonal. Diagonal[m, -k] gives diagonals below.
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]=
New in 6