How to make a lower triangular matrix in Matlab and Octave
To extract a lower triangular matrix in Matlab and Octave, use the function tril()
tril(M)
The M parameter is an array.
The tril() function returns a lower triangular matrix.
What is a lower triangular matrix? It is a matrix in which all values above the main diagonal are null. Therefore, the non-null values are on the main diagonal and below the main diagonal. For example $$ T = \begin{pmatrix} 1 & 0 & 0 \\ 2 & 3 & 0 \\ 4 & 5 & 6 \end{pmatrix} $$
Example
Create a 3x3 matrix
>> M=[ 1 2 3 ; 4 5 6 ; 7 8 9 ]
M =
1 2 3
4 5 6
7 8 9
To extract the lower triangular matrix type tril(M)
>> tril(M)
ans =
1 0 0
4 5 0
7 8 9
The tril() function returns the lower triangular matrix of matrix M.