Main Content

istril

Determine if matrix is lower triangular

Description

example

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

Examples

collapse all

Create a 5-by-5 matrix.

D = tril(magic(5))
D =5×517 0 0 0 0 23 5 0 0 0 4 6 13 0 0 10 12 19 21 0 11 18 25 2 9

TestDto see if it is lower triangular.

istril(D)
ans =logical1

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

Create a 5-by-5 matrix of zeros.

Z = zeros(5);

TestZto see if it is lower triangular.

istril (Z)
ans =logical1

The result is logical1(true) because a lower triangular matrix can have any number of zeros on its main diagonal.

Input Arguments

collapse all

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

Data Types:single|double
Complex Number Support:Yes

More About

collapse all

Lower Triangular Matrix

A matrix is lower triangular if all elements above the main diagonal are zero. Any number of the elements on the main diagonal can also be zero.

For example, the matrix

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

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

Tips

  • Use thetril函数产生lower triangular matrices for whichistrilreturns 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,istril(A) == isbanded(A,size(A,1),0).

Extended Capabilities

Introduced in R2014a