Chose a random integer between an upper and lower limit.

6 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 1 de Mayo de 2014
Editada: Azzi Abdelmalek el 1 de Mayo de 2014
c=randi([a b])

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by