Documentation

istriu

Determine if matrix is upper triangular

Syntax

tf = istriu(A)

Description

example

tf = istriu(A)returns logical1(true) ifAis anupper triangular matrix; otherwise, it returns logical0(false).

Examples

collapse all

Create a 5-by-5 matrix.

A = triu(magic(5))
A =5×517 24 1 8 15 0 5 7 14 16 0 0 13 20 22 0 0 0 21 3 0 0 0 0 9

TestAto see if it is upper triangular.

istriu(A)
ans =logical1

The result is logical1(true) because all elements below the main diagonal are zero.

Create a 5-by-5 matrix of zeros.

Z = zeros(5);

TestZto see if it is upper triangular.

istriu(Z)
ans =logical1

The result is logical1(true) because an upper triangular matrix can have any number of zeros on the main diagonal.

Input Arguments

collapse all

Input array, specified as a numeric array.istriureturns logical0(false) ifAhas more than two dimensions.

Data Types:single|double
Complex Number Support:Yes

More About

collapse all

Upper Triangular Matrix

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

A = ( 1 1 1 1 0 1 2 2 0 0 1 3 0 0 0 1 )

is upper triangular. A diagonal matrix is both upper and lower triangular.

Tips

  • Use thetriu函数produce upper triangular matrices for whichistriureturns logical1(true).

  • The functionsisdiag,istriu, andistrilare special cases of the functionisbanded, which can perform all of the same tests with suitably defined upper and lower bandwidths. For example,istriu(A) == isbanded(A,0,size(A,2)).

Extended Capabilities

Introduced in R2014a

Was this topic helpful?