mardi 13 septembre 2022

Selecting a random value from vector but excluding particular values

I thought this was an easy one but I cannot find any solution for it.

I have this vector called cues= ["R" "B" "C" "P" "Y" "G"]; from which I want to randomly select one value, but excluding one (or two) of the values each time.

For example, I would like to get a random value from the vector excluding the "R" value, or in a second condition I would like "R" and "Y" not to be selected from the sample.

I have tried using randsample and randperm but neither of them seems to include this option. Any help very much appreciated!

Thanks, Mikel




Aucun commentaire:

Enregistrer un commentaire