gives the list of elements on the leading diagonal of the matrix m.
gives the elements on the k 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.
Basic Examples (3)
Give the diagonal elements of a matrix:
Give diagonals one element above and below the leading diagonal:
Give a diagonal of a nonsquare matrix:
Properties & Relations (3)