vendredi 19 juin 2020

How to balance unique values in an array Matlab

I have a vector

Y = [1 1 0 0 0 1 1 0 1 0 1 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 0 0 0 1 0 0 0]

1 occurs 17 times

0 occurs 21 times

How can I randomly remove 0s so that both values have equal amounts, such as 1 (17 times) and 0 (17 times)?

This should also work on much bigger matrix.




Aucun commentaire:

Enregistrer un commentaire