# istril

Determine if matrix is lower triangular

## Syntax

``tf = istril(A)``

## Description

````tf = istril(A)` returns logical `1` (`true`) if `A` is a lower triangular matrix. Otherwise, it returns logical `0` (`false`).```

example

## Examples

collapse all

Create a 5-by-5 matrix.

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

Test if the matrix is lower triangular.

`istril(A)`
```ans = logical 1 ```

The matrix is lower triangular because all elements above the main diagonal are zero.

Create a 5-by-5 matrix of zeros. Test if the matrix is lower triangular.

```Z = zeros(5); istril(Z)```
```ans = logical 1 ```

The result is logical `1` (`true`) because a lower triangular matrix can have any number of zeros on the main diagonal.

## Input Arguments

collapse all

Input array. `istril` returns logical `0` (`false`) if `A` has more than two dimensions.

Data Types: `single` | `double` | `logical`
Complex Number Support: Yes

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, this matrix is lower triangular.

`$A=\left(\begin{array}{cccc}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}1& \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}0& \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}0& 0\\ -1& \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}1& \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}0& 0\\ -2& -2& \text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}1& 0\\ -3& -3& -3& 1\end{array}\right)$`

A diagonal matrix is both upper and lower triangular.

## Tips

• Use the `tril` function to produce lower triangular matrices for which `istril` returns logical `1` (`true`).

• The functions `isdiag`, `istriu`, and `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, ```istril(A) == isbanded(A,size(A,1),0)```.

## Version History

Introduced in R2014a