Generate a random binary matrix with given rank by using minimum number of 1s
9 views (last 30 days)
Show older comments
Efe Berkay Yitim
on 16 Feb 2023
Answered: Efe Berkay Yitim
on 16 Feb 2023
Hi,
I am generating a random binary matrix with size ky x w with rank min(ky,w) with the code given below. However, because I am not constraining the possibility to select 0 or 1 as an element of a matrix, number of 0s and 1s are almost equal to each other. I need to create this matrix with rank min(ky,w) using minimum number of 1s. How can I achieve this, any suggestion?
k = 5;
y = 20;
w = 104;
A = randi([0 1], k*y, w);
while gfrank(A) ~= min(k*y, w)
A = randi([0 1], k*y, w);
end
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!