I realized that since randi(IMAX, m, n) forms the mxn matrix with as many columns as possible, you can create an nxn A matrix with k rotary columns and random elements between 1 and IMAX with the following code:
A = randi(IMAX, n, k)*randi(IMAX, k, n)
Since each of randi(IMAX, n, k) and randi(IMAX, k, n) has only columns with rotary columns k , therefore their product will have only k columns.
user1214845
source share