# istriu

Determine if a matrix is upper triangular

### istriu(A)

• A is an array, which can be real or complex.
• If all elements below the main diagonal of A are zeros, it returns logical 1.
• When A is complex, it returns logical 1 if both istriu(imag(A)) and istriu(real(A)) are true.
• If A is empty, it returns logical 1.

Example 1:

% istriu gives 1 for the following matrices
a=zeros(3,4)
istriu(a)

a=triu(rand(4))
istriu(a)

a=[zeros(4,1) triu(rand(4))]
istriu(a)

a=diag(rand(1,4))
istriu(a)

% istriu gives 0 for the following matrix
a=[ones(4,1) triu(rand(4))]
istriu(a)
a =
0.000   0.000   0.000   0.000
0.000   0.000   0.000   0.000
0.000   0.000   0.000   0.000

ans =
1

a = 1e-1 ×
5.452   4.410   4.992   3.122
0.000   5.807   2.578   8.286
0.000   0.000   2.539   7.768
0.000   0.000   0.000   8.847

ans =
1

a = 1e-1 ×
0.000   9.884   9.713   0.963   9.099
0.000   0.000   8.141   6.661   3.406
0.000   0.000   0.000   1.038   3.211
0.000   0.000   0.000   0.000   1.731

ans =
1

a = 1e-1 ×
5.255   0.000   0.000   0.000
0.000   4.355   0.000   0.000
0.000   0.000   8.285   0.000
0.000   0.000   0.000   8.537

ans =
1

a =
1.000   0.345   0.731   0.856   0.399
1.000   0.000   0.433   0.905   0.464
1.000   0.000   0.000   0.842   0.487
1.000   0.000   0.000   0.000   0.705

ans =
0