Chose a random integer between an upper and lower limit.

2 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 1 Mag 2014
Modificato: Azzi Abdelmalek il 1 Mag 2014
c=randi([a b])

Più risposte (0)

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by