matrix of zeros and ones within number of zeros in each rows in-between a limit
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Biswanath Mahanty
il 9 Ott 2015
Commentato: Image Analyst
il 10 Ott 2015
want to have a 30x40 matrix of zeros and ones; however in each row total number of 'ones' must be within 10 to 20.
0 Commenti
Risposta accettata
Più risposte (1)
John D'Errico
il 9 Ott 2015
So generate a matrix with random ones and zeros. Discard any rows that fail this test, and regenerate just those rows. WTP?
Since you have not said what the distribution of the number of ones is, I cannot offer a complete solution, but it is simple in any case. If you will have 17 ones in a row, then generate a row vector with 17 ones, and 23 zeros. Then randomly permute the elements.
0 Commenti
Vedere anche
Categorie
Scopri di più su Random Number Generation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!