Chose a random integer between an upper and lower limit.

6 vues (au cours des 30 derniers jours)
Giuseppe
Giuseppe le 1 Mai 2014
I ask the user to input two limits a upper and lower limit. I then want to generate a random integer between these two values.
I tried using for example:
a = input('enter a'); %lower
b = input('enter b'); %upper
c = randi(b,a)
Although this seems to create a vector I just want a scalar?

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 1 Mai 2014
Modifié(e) : Azzi Abdelmalek le 1 Mai 2014
c=randi([a b])

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by