generate pair numbers randomly
12 ビュー (過去 30 日間)
古いコメントを表示
I want to pair two numbers randomly in each pair as [ 5 8] [ 11 4] [3 17] .....
1 件のコメント
Image Analyst
2022 年 7 月 11 日
Are repeats, either in the same row or in different rows, allowed? Or do all numbers need to be different? Must the numbers be integers, or can they be floating point/fractional?
回答 (2 件)
Hrusheekesh
2022 年 7 月 11 日
hi ananya,
it is my understanding that you want to create a array of pairs with random vaues. but is there any constraints like the range or max value.
anyways if there is a value try this
a=20;
idx=reshape(randperm(a,[],2);
0 件のコメント
KSSV
2022 年 7 月 11 日
Say you want to pair numbers randomly between 1 to 20.
n = 10 ;
iwant = zeros(n,2) ;
for i = 1:n
iwant(i,:) = randperm(20,2) ;
end
iwant
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!