Find a non-singular sub-matrix in a full-rank matrix.

MATLABmatrices

Suppose we are given $A\in\mathbb{R}^{n\times m}$, where $n<m$, and we know that $A$ is a full-rank matrix. What is a simple and efficient way to find any submatrix $B\in\mathbb{R}^{n\times n}$ constructed of columns of $A$, such that $B$ is not singular?
I want to have a Matlab function of the form [ind]=find_B(A) that returns indices of the columns of $A$ that allow constructing $B$.

Best Answer

These $n$ columns will form a basis of the column space of $A$. If you perform a row reduction the columns containing a leading $1$ will form such a basis. If you use the Matlab command

[R,p] = rref(A)

the indices of those columns should be returned in p.