triu

  • triu(X) returns the upper triangular matrix of X
  • triu(X,k) returns the elements of X, on and below its k-th diagonal

Examples

> X = ones(3)

[X:3x3 double]

> triu(X)#

            1     1     1
            0     1     1
            0     0     1

> triu(X,-1)#

            1     1     1
            1     1     1
            0     1     1

> triu(X, 1)#

            0     1     1
            0     0     1
            0     0     0
 

Resources

See also

diag | ismatrix | tril