How is the rank function used in MATLAB?

The rank function in MATLAB is used to calculate the rank of a matrix. Its usage is as follows:

  1. For a square matrix A, the function rank(A) returns the rank of matrix A.
A = [1 2 3; 4 5 6; 7 8 9];
r = rank(A); % 返回3
  1. For a non-square matrix A, rank(A) returns the smaller of the column rank and row rank of matrix A.
A = [1 2 3; 4 5 6];
r = rank(A); % 返回2

The rank function also supports inputting an additional tolerance value to determine the difference between the singular values of a matrix and 0. For example, rank(A, tol) means that when determining the rank of a matrix, values with a difference from 0 less than tol will be considered as 0.

A = [1 2 3; 4 5 6; 7 8 9];
r = rank(A, 1e-10); % 返回3,不考虑很接近于0的奇异值
bannerAds