samedi 22 octobre 2016

Random matlab matrix with at least .4 and at most .6 ones per column

I'm creating a matrix in matlab of size n that contains only ones and zeros. The easiest way to do that is round(rand(m,n)) for a matrix of size mxn, but it creates in some cases rows that have all zeros or all ones. I want to put a lower and upper bound in the number of ones that each row has. Is there an easy way to do that?

Thanks




Aucun commentaire:

Enregistrer un commentaire