how to generate 10 random numbers each between 1 to 100 then 101 to 200 etc. till 1000?

54 views (last 30 days)
total no. generated should be 100. 10 between 1 to 100 then next 10 between 101 to 200 etc.

Answers (3)

Jan
Jan on 28 Jun 2017
Edited: Jan on 28 Jun 2017
Perhaps:
X = randi([0, 99], 10, 10) + (1:100:1000); % requires Matlab >= 2016b
With older versions:
X = bsxfun(@plus, randi([0, 99], 10, 10), 1:100:1000);
If floating point numbers are wanted, see KSSV's method:
X = (1 + 99 * rand(10, 10)) + (1:100:1000);
Again: for older versions:
X = bsxfun(@plus, (1 + 99 * rand(10, 10)), 1:100:1000);

KSSV
KSSV on 28 Jun 2017
To generate 10 random number between 1 and 100 use:
a = 1;
b = 100;
r = (b-a).*rand(10,1) + a;

Linus Antonio Ofori Agyekum
how do i generate 1000 point random integers with 4 levels?

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!