triu

Returns a upper triangular matrix.

Syntax

triu(x)

triu(x, k)

Inputs

X
The matrix from which to extract the result.
Dimension: matrix
k
The index of the sub or super-diagonal at which to begin (default: 0).
Type: integer
Dimension: scalar

Outputs

R
The upper triangular matrix.

Examples

triu([1,2,3,4,5;6,7,8,9,10;11,12,13,14,15])
R = [Matrix] 3 x 5
1  2   3   4   5
0  7   8   9  10
0  0  13  14  15
triu([1,2,3,4,5;6,7,8,9,10;11,12,13,14,15],2)
R = [Matrix] 3 x 5
0  0  3  4   5
0  0  0  9  10
0  0  0  0  15