How do I create random Boolean array with at least one 1 in each row?
44 views (last 30 days)
Show older comments
How do I create random Boolean array with at least one 1 in each row?
0 Comments
Answers (1)
James Tursa
on 31 Mar 2015
Edited: James Tursa
on 31 Mar 2015
For a row, e.g.,
n = number of random numbers in a row
row = randi(2,1,n)-1;
while( ~any(row) )
row = randi(2,1,n)-1;
end
0 Comments
See Also
Categories
Find more on Random Number Generation 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!