\section{RANK Calculate the Rank of a Matrix}

\subsection{Usage}

Returns the rank of a matrix.  There are two ways to use
the \verb|rank| function is
\begin{verbatim}
   y = rank(A,tol)
\end{verbatim}
where \verb|tol| is the tolerance to use when computing the
rank.  The second form is
\begin{verbatim}
   y = rank(A)
\end{verbatim}
in which case the tolerance \verb|tol| is chosen as
\begin{verbatim}
   tol = max(size(A))*max(s)*eps,
\end{verbatim}
where \verb|s| is the vector of singular values of \verb|A|.  The
rank is computed using the singular value decomposition \verb|svd|.
\subsection{Examples}

Some examples of matrix rank calculations
\begin{verbatim}
--> 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  

\end{verbatim}
Here we construct an ill-conditioned matrix, and show the use 
of the \verb|tol| argument.
\begin{verbatim}
--> A = [1,0;0,eps/2]
A = 
  <double>  - size: [2 2]
 
Columns 1 to 2
 1.0000000000000000e+00  0.0000000000000000e+00  
 0.0000000000000000e+00  1.1102230246251565e-16  
--> rank(A)
ans = 
  <int32>  - size: [1 1]
 1  
--> rank(A,eps/8)
ans = 
  <int32>  - size: [1 1]
 2  

\end{verbatim}
