Generating random integer from -x to x
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I need to find a way to generate a random integer from -x to x for example -5 to 5
0 commentaires
Réponse acceptée
Plus de réponses (1)
per isakson
le 12 Mar 2014
Modifié(e) : per isakson
le 12 Mar 2014
2*x*rand-x produces uniformly distributed numbers
Doc says: Example 1, Generate values from the uniform distribution on the interval [a, b]:
r = a + (b-a).*rand(100,1);
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!