Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use the commands rand and round to make a random 10-by-10 matrix A with entries

ID: 2970089 • Letter: U

Question

Use the commands rand and round to make a random 10-by-10 matrix A with entries 0 or 1. Test using rref whether the matrix A has full rank. If not, repeat generating random 10-by-10 matrices with entries 0 and 1 until it has full rank. Record how often you had to repeat.
Next, form m-by-n submatrices out of the first m rows and the first n columns of A, for at least 6 different choices of m and n (neither m nor n repeats), by B=A(1:m,1:n). Comment on the rank of the resulting matrices and explain why this happens. You do not need to submit a printout of your experiments, just explain why the ranks of the submatrices come out the way they do.
Hints: What is the maximal possible rank of an m-by-n matrix? Is this rank always assumed for the submatrices?

Explanation / Answer

n = 10;

count = 0;

% for i = 1:1000

    A = rand(n);

    A = round(A);

    R = rref(A);

    k = rank(R);

    if(k ~= 10)

        count = count+1;

    end

% end

% prob = k/1000;

s_m = 0;

for m = 4:9

    for n = 3:8

        s_m = s_m + 1;

        B = A(1:m,1:n);

        kk = rank(B);

        fprintf('Rank of submatrix %d is %d ',s_m,kk);

    end

end


NOTE:

1 - To record how often you have to repeat to get matrix A of full rank, you can check the probability of not getting matrix A of full rank. For thousand runs, I got it around 0.1, so that means you will get matrix A of full rank 90% of times.
(You can check this in the code by removing '%' in code and checking value of prob(Probability of not getting matrix A of full length)

2 - For submatrix B of m * n -

(A) - Rank will always be less than or equal to rank of A

(B) - Rank will always be less than or equal to minimum of m or n
->
Column and Row ranks of any matrix are equal so it can not exceed minimum of m or n. Also, if let's say n is minimum but column rank is n-1, then from above statement it follows that rank of B will be less than n - which is minimum of m or n.