Effacer les filtres
Effacer les filtres

random integers in a customized ranges

1 vue (au cours des 30 derniers jours)
Dam
Dam le 6 Juin 2018
Commenté : Dam le 12 Juin 2018
to find 100 random integers between 1 and 5000 we use: x = randi(5000,100,1); is there a way to find random integers between 1 and 5000 excluding the numbers between 2000 and 25000 and between 4000 and 4500 for example thank you

Réponse acceptée

KSSV
KSSV le 6 Juin 2018
x = randi(5000,1000,1); % make more number of random integers
% remove the unwanted
x(x>=2000 & x<=2500) = [] ;
x(x>=4000 & x<=4500) = [] ;
% now pick 100 out of it
idx = randperm(length(x),100) ;
iwant = x(idx) ;
  1 commentaire
Dam
Dam le 12 Juin 2018
thank you very much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by