There are a number of ways to compute the rank of a matrix. MATLAB® software
uses the method based on the singular value decomposition, or SVD.
The SVD algorithm is the most time consuming, but also the most reliable.
The rank algorithm is
s = svd(A);
tol = max(size(A))*eps(max(s));
r = sum(s > tol);