How do I create random Boolean array with at least one 1 in each row?

답변 (1개)

James Tursa
James Tursa 2015년 3월 31일
편집: James Tursa 2015년 3월 31일
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

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2015년 3월 31일

편집:

2015년 3월 31일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by