u = triu(X)u = triu(X,k)
triu(X) is the upper triangular part of X.
triu(X,k) is the element on and above the k-th 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 11 1 1 10 1 1 10 0 1 1
diag,tril
(c) Copyright 1994 by The MathWorks, Inc.