# How can I find all possible square submatrices of a given non-square matrix?

Lets say the non-square matrix is $n \times r$ where $n > r$ (# of rows is greater than # of columns). I'd like to find all $r \times r$ submatrices. What is really required is that I have to find and have all square submatrices simultaneously in order to compare their determinants at the same time. Here is the $6 \times 4$ matrix that I have. I need to find all fifteen $4 \times 4$ submatrices.

\begin{array}{cccc} 0 & -\text{Sin}\left[\theta _C\right] l_G & -\text{Sin}\left[\theta _D\right] l_C & 0 \\ 0 & \text{Cos}\left[\theta _C\right] l_G & \text{Cos}\left[\theta _D\right] l_C & 0 \\ -\text{Sin}\left[\theta _B\right] l_C & 0 & \text{Sin}\left[\theta _D\right] l_C & 0 \\ \text{Cos}\left[\theta _B\right] l_C & 0 & -\text{Cos}\left[\theta _D\right] l_C & 0 \\ 0 & \text{Sin}\left[\theta _C\right] l_G & \text{Sin}\left[\theta _D\right] l_C & -\text{Sin}\left[\theta _F\right] l_G \\ 0 & -\text{Cos}\left[\theta _C\right] l_G & -\text{Cos}\left[\theta _D\right] l_C & \text{Cos}\left[\theta _F\right] l_G \\ \end{array}

• Please include a Mathematica-formatted version of your matrix. You are less likely to get an answer if the answerer needs to re-type everything Aug 14, 2016 at 23:46

Subsets[mat, {4}]

Replace mat with your matrix.
subMatrices[mat_List] := Subsets[mat, Dimensions[mat][[{2}]]]