Skip to content

rank

Matrix Rank

rank(A)

  • It returns the rank of a matrix A.
  • More specifically, it returns the number of singular values of A larger than the tolerance:
max(size(A))*eps(norm(A)).
  • A should be a matrix, i.e., ndims(A)=2, and should contain no inf and nan values.
  • It returns 0 if A is empty.

Example 1: A below has rank 2.

A=[1 0 0 0;0 1 0 0;0 1 0 0];
rank(A)
ans =
 2.000

rank(A, tol)

  • A is the same as specified above for rank(A).
  • tol is the tolerance, which must be real.
  • It returns the number of singular values of A larger than tol.
  • It returns 0 if A is empty, or tol is either inf or nan.

Example 2: Using the default tolerance tol=max(size(A))*eps(norm(A)), rank(A) and rank(A,tol) give the same results.

A=[1 2 3 4;1 2 3 4;0 1 0 0]
r1=rank(A)
tol=max(size(A))*eps(norm(A))
r2=rank(A,tol)
A =
 1.000   2.000   3.000   4.000
 1.000   2.000   3.000   4.000
 0.000   1.000   0.000   0.000

r1 =
 2.000

tol = 1e-15 ×
 3.553

r2 =
 2.000