mercredi 20 mai 2015

How to randomly generate a matrix with n 0s and m 1s in Matlab?

For example, how to randomly generate a 1-by-12 matrix that contains 4 0s and 8 1s?

Like this matrix [1 0 0 1 0 0 0 1 0 0 1 0]

And if I generate again, it returns a different matrix [0 0 1 0 0 1 1 0 1 0 0 0]




Aucun commentaire:

Enregistrer un commentaire