MATLAB Function Reference | Search  Help Desk |
triu | Examples See Also |
Upper triangular part of a matrix
U = triu(X) U = triu(X,k)
U = triu(X)
returns the upper triangular part of X
.
U = triu(X,k)
returns the element on and above the kth diagonal of X
. k = 0
is the main diagonal, k > 0
is above the main diagonal, and k < 0
is below the main diagonal.triu(ones(4,4),-1)
is
1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1
diag
Diagonal matrices and diagonals of a matrix
tril
Lower triangular part of a matrix