Clear Filters
Clear Filters

How can I randomly generate data pairs?

4 views (last 30 days)
Yusha Wang
Yusha Wang on 15 Jan 2018
Answered: Prasanth Sunkara on 16 Feb 2018
I want to have 10000 randomly pairs such that on the range [0,4]x[0,1]

Answers (1)

Prasanth Sunkara
Prasanth Sunkara on 16 Feb 2018
Hi Yusha, There are multiple ways to do that. One way is using randi to generate each column with the appropriate constraints and concatenate them later as shown below:
z=randi([0 4],1000,1);
x=randi([0 1],1000,1);
randomPairs = [z x];
Let me know if this helps.


Find more on 随机数生成 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!