I am wondering how it is possible to generate an n x n matrix in Matlab with a specific rank (number of pivot columns). I know that you can use the command randi(IMAX, m, n) to generate an m x n matrix with random entries between 1 and IMAX, but is it possible, for example, to generate a 4 x 4 matrix with random entries but only 2 pivot columns? Thanks in advance.
I am wondering how it is possible to generate an n x n matrix
Share
I realized that because
randi(IMAX, m, n)forms an m x n matrix with as many pivot columns as possible, that it’s possible to form an n x n matrix A with k pivot columns and random entries between 1 and IMAX with the following code:Because each of
randi(IMAX, n, k)andrandi(IMAX, k, n)only havekpivot columns so their product will only have k pivot columns as well.