Determine if matrix is upper triangular
tf = istriu(A)
Create a 5-by-5 matrix.
A = triu(magic(5))
A = 17 24 1 8 15 0 5 7 14 16 0 0 13 20 22 0 0 0 21 3 0 0 0 0 9
A to see if it is upper triangular.
ans = 1
The result is logical
true) because all elements below the main diagonal are zero.
A matrix is upper triangular if all elements below the main diagonal are zero. Any number of the elements on the main diagonal can also be zero.
For example, the matrix
is upper triangular. A diagonal matrix is both upper and lower triangular.
to produce upper triangular matrices for which
istril are special cases of the function
isbanded, which can perform all of the
same tests with suitably defined upper and lower bandwidths. For example,