lettura simple

Rank of a matrix in Octave

In this tutorial, I will provide a step-by-step guide on determining the rank of a matrix in Octave

What is rank? The rank of a matrix refers to the maximum number of linearly independent rows or columns within the matrix. It signifies the dimension of the vector space formed by the column vectors. For instance, let's consider the following matrix: $$ rank \begin{pmatrix} 1 & 2 \\ 1 & 2 \end{pmatrix} = 1 $$ In this case, the matrix has only one linearly independent column since the two column vectors are linearly dependent on each other. We can express one vector in terms of the other: $$ \begin{pmatrix} 2 \\ 2 \end{pmatrix} = 2 \cdot \begin{pmatrix} 1 \\ 1 \end{pmatrix} $$

Now, let's move on to a practical example.

First, define a 3x3 matrix with three rows and three columns and assign it to the variable M:

>> M = [ 1 2 3 ; 4 5 6 ; 7 8 9 ]
M =
1 2 3
4 5 6
7 8 9

To find the rank of the matrix, use the rank(M) function

>> rank(M)
ans = 2

The rank of the matrix is equal to 2.

Verify this result by checking the determinant of the 3x3 matrix. $$ \det \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix} = 0 $$ The determinant is zero. This implies that the rank cannot be 3. Continuing the verification process, analyze the determinant of the 2x2 submatrices. $$ \det \begin{pmatrix} 1 & 2 \\ 4 & 5 \end{pmatrix} = 1 \cdot 5 - 2 \cdot 4 = 5 - 8 = -3 $$ At least one 2x2 submatrix possesses a non-zero determinant. Consequently, the rank of matrix M is 2.




Report a mistake or post a question




FacebookTwitterLinkedinLinkedin