lettura simple

Rank of a Matrix in Matlab

In this lesson, I will explain how to calculate the rank of a matrix in Matlab.

What is the matrix rank? The rank of a matrix is the highest number of linearly independent rows or columns in the matrix. It represents the dimension of the vector space generated by the column vectors. For example, if a matrix has only one linearly independent column, its rank would be 1: $$ rank \begin{pmatrix} 1 & 2 \\ 1 & 2 \end{pmatrix} = 1 $$ This is because the two column vectors are linearly dependent on each other, and one can be expressed as a multiple of the other: $$ \begin{pmatrix} 2 \\ 2 \end{pmatrix} = 2 \cdot \begin{pmatrix} 1 \\ 1 \end{pmatrix} $$

Let's go through a practical example.

Create a 3x3 matrix with three rows and three columns:

>> 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, simply use the rank(M) command.

>> rank(M)
ans = 2

The rank of the matrix is 2.

Verification. You can manually perform calculations to verify if the result is correct. The determinant of a 3x3 matrix is zero: $$ \det \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix} = 0 $$ Therefore, the matrix cannot have a rank equal to 3. Next, check if there exists a 2x2 submatrix with a non-zero determinant. $$ \det \begin{pmatrix} 1 & 2 \\ 4 & 5 \end{pmatrix} = 1 \cdot 5 - 2 \cdot 4 = 5 - 8 = -3 $$ The submatrix has a non-zero determinant, indicating that the rank of matrix M is 2.




Report a mistake or post a question




FacebookTwitterLinkedinLinkedin