tril
Lower-triangular part of a matrix.
Syntax
Section titled “Syntax”L = tril(X)L = tril(X, k)Description
Section titled “Description”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.
Examples
Section titled “Examples”tril(magic(4)) % keep main diagonal and belowtril(magic(4), -1) % strict lower (zero out main diagonal too)tril(magic(4), 1) % keep main diagonal and one row above