Skip to content

tril

Lower-triangular part of a matrix.

L = tril(X)
L = tril(X, k)

Returns a matrix the same size as X containing only the lower-triangular elements; everything above the main diagonal is zeroed. With the optional k offset, shifts the boundary: positive k keeps k superdiagonals; negative k removes |k| subdiagonals.

tril(magic(4)) % keep main diagonal and below
tril(magic(4), -1) % strict lower (zero out main diagonal too)
tril(magic(4), 1) % keep main diagonal and one row above
  • triu — Upper-triangular part of a matrix.
  • diag — Extract a diagonal, or build a matrix from a diagonal.