I found a nice way to generate a random $5\times 7$ matrix with rank 3.
MatrixForm[A = RandomInteger[5, {5, 3}].RandomInteger[5, {3, 7}]]
MatrixRank[A]
Let me store an example output, because each time we use RandomInteger, the matrix changes. So, we'll work with this one, an output from the strategy above.
A = {{18, 29, 20, 17, 37, 22, 38}, {12, 16, 10, 4, 14, 14, 16}, {6,
16, 12, 17, 28, 9, 27}, {10, 11, 9, 6, 18, 10, 17}, {14, 20, 17,
18, 39, 15, 36}}
If we use:
MatrixForm[RowReduce[A]]
Then we can identify the pivot columns. Then we can select the pivot columns and store them in matC.
MatrixForm[matC = A[[All, 1 ;; 3]]]
I am just wondering if there is a cute Mathematica command I haven't encountered that will automatically select the independent columns or the independent rows of a matrix.
NullSpace
of the matrix. $\endgroup$pair={SeedRandom[#];A=RandomInteger[5,{5,3}].RandomInteger[5,{3,7}];MatrixRank[A],#}&/@Range[10000]; Select[pair,First[#]!=3&]
,I mean you have a probability of 0.08% to get a matrix whose rank is not 3 by your method. :) $\endgroup$