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
2013-2-23
编辑:Azzi Abdelmalek
2013-2-23
[randi(100,1,100);randi(100,1,100)+199]
2 个评论
Jan
2013-2-24
Then the upper range is from 200 to 299 only.
Azzi Abdelmalek
2013-2-24
Yes, it should be
randi(101,1,100)+199
Jan
2013-2-24
a = randi([1, 201], 1, 100)
a(a > 100) = a(a > 100) + 99;
类别
在 帮助中心 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!