Random numbers within 2 ranges

Is it possible to generate random numbers within 2 ranges but for the same purpose.
e.g. from 1-100 & 200-300, with all the results output together?
Thanks
~N~

Respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 23 de Feb. de 2013
Editada: Azzi Abdelmalek el 23 de Feb. de 2013

0 votos

[randi(100,1,100);randi(100,1,100)+199]

2 comentarios

Jan
Jan el 24 de Feb. de 2013
Then the upper range is from 200 to 299 only.
Yes, it should be
randi(101,1,100)+199

Iniciar sesión para comentar.

Jan
Jan el 24 de Feb. de 2013

0 votos

a = randi([1, 201], 1, 100)
a(a > 100) = a(a > 100) + 99;

Categorías

Más información sobre Random Number Generation en Centro de ayuda y File Exchange.

Preguntada:

N
N
el 23 de Feb. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by