How i can insert a random integer between two numbers?

1 vue (au cours des 30 derniers jours)
Giannakis Stoukas
Giannakis Stoukas le 22 Avr 2015
I have a variable and i want it to take a randome integer between numbers 2 and 101

Réponses (2)

Thomas Koelen
Thomas Koelen le 22 Avr 2015
Modifié(e) : Thomas Koelen le 22 Avr 2015
a=uint16(2+rand*99)

Star Strider
Star Strider le 22 Avr 2015
The randi function is perfect for this:
rv = randi([2 101]);

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