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~

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 23일
편집: Azzi Abdelmalek 2013년 2월 23일

0 개 추천

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

댓글 수: 2

Jan
Jan 2013년 2월 24일
Then the upper range is from 200 to 299 only.
Yes, it should be
randi(101,1,100)+199

댓글을 달려면 로그인하십시오.

Jan
Jan 2013년 2월 24일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

N
N
2013년 2월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by