Symbolic Math Toolbox | ![]() ![]() |
Syntax
triu(X) triu(X, K)
Description
triu(X)
is the upper triangular part of X
.
triu(X, K)
returns an upper triangular matrix that retains the elements of X
on and above the k
-th diagonal and sets the remaining elements to 0. The values k=0
, k>0
, and k<0
correspond to the main, superdiagonals, and subdiagonals, respectively.
A = [ a, b, c ] [ 1, 2, 3 ] [ a+1, b+2, c+3 ]Then
triu(A)
returns
[ a, b, c ] [ 0, 2, 3 ] [ 0, 0, c+3 ]
triu(A,1)
returns
[ 0, b, c ] [ 0, 0, 3 ] [ 0, 0, 0 ]
triu(A,-1)
returns
[ a, b, c ] [ 1, 2, 3 ] [ 0, b+2, c+3 ]
![]() | tril | vpa | ![]() |