triu
- :
u =triu(x)¶ - :
u =triu(x, k)¶ Extract the upper triangular portion of x, zeroing every entry that lies below the main diagonal.
The optional integer k selects which diagonal bounds the result: with k equal to 0 (the default) the main diagonal and everything above it is kept; a positive k drops that many diagonals up from the main one; a negative k additionally keeps that many subdiagonals below the main one. A sparse x produces a sparse result.