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.
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 24 日
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 ExchangeRandom 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