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}

  • 1
    $\begingroup$ 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 $\endgroup$ Aug 14 '16 at 23:46
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Siav Josep
    Aug 15 '16 at 0:28
Subsets[mat, {4}]

Replace mat with your matrix.

Or, more generally:

subMatrices[mat_List] := Subsets[mat, Dimensions[mat][[{2}]]]
  • $\begingroup$ Thanks your answer, but it does not work in a MatrixForm. It is just working when I Flatten the matrix, but it turns the matrix into an array of 48 elements! $\endgroup$
    – Ham64
    Aug 24 '16 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.