How can I randomly generate data pairs?

조회 수: 4 (최근 30일)
Yusha Wang
Yusha Wang 2018년 1월 15일
답변: Prasanth Sunkara 2018년 2월 16일
I want to have 10000 randomly pairs such that on the range [0,4]x[0,1]

답변 (1개)

Prasanth Sunkara
Prasanth Sunkara 2018년 2월 16일
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.
-Prasanth

카테고리

Help CenterFile Exchange에서 随机数生成에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!