next up previous contents
Next: RESHAPE Reshape Array Up: Array Generation and Manipulations Previous: PINV Moore-Penrose Pseudoinverse   Contents

Subsections

RANK Calculate the Rank of a Matrix

Usage

Returns the rank of a matrix. There are two ways to use the rank function is

   y = rank(A,tol)

where tol is the tolerance to use when computing the rank. The second form is

   y = rank(A)

in which case the tolerance tol is chosen as

   tol = max(size(A))*max(s)*eps,

where s is the vector of singular values of A. The rank is computed using the singular value decomposition svd.

Examples

Some examples of matrix rank calculations

--> rank([1,3,2;4,5,6])
ans = 
  <int32>  - size: [1 1]
             2  
--> rank([1,2,3;2,4,6])
ans = 
  <int32>  - size: [1 1]
             1

Here we construct an ill-conditioned matrix, and show the use of the tol argument.

--> A = [1,0;0,eps/2]
A = 
  <double>  - size: [2 2]
 
Columns 1 to 2
    1.000000000000000         0.000000000000000      
    0.000000000000000         5.55111512312578e-17   
--> rank(A)
ans = 
  <int32>  - size: [1 1]
             1  
--> rank(A,eps/8)
ans = 
  <int32>  - size: [1 1]
             2


Samit K. Basu 2005-03-16