Chose a random integer between an upper and lower limit.

3 views (last 30 days)
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?

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 1 May 2014
Edited: Azzi Abdelmalek on 1 May 2014
c=randi([a b])

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!