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?

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 1 日
編集済み: Azzi Abdelmalek 2014 年 5 月 1 日

1 投票

c=randi([a b])

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Random Number Generation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by