random number from a set of define numbers

1 vue (au cours des 30 derniers jours)
eyal lampel
eyal lampel le 21 Sep 2015
Commenté : eyal lampel le 21 Sep 2015
hello all , i am trying to simulate a lottery , i need to chose 6 random numbers from 1 to 37 . i have a set of "HOT number" that i want half of the 6 random number will be from that set of "HOT number" a number CANNOT repeat itself. example: "HOT numbers" - { 3,11,29,30,33,35}
system output - { 3, 29, 33,22,12,8} { 11, 33, 35,37,1,28}

Réponse acceptée

James Tursa
James Tursa le 21 Sep 2015
Try this:
HOT = [3,11,29,30,33,35];
OTHER = 1:37:
OTHER(HOT) = [];
x = randperm(6,3);
y = randperm(31,3);
picks = [HOT(x) OTHER(y)];
  1 commentaire
eyal lampel
eyal lampel le 21 Sep 2015
thank you. Thats brilliant .

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by