フィルターのクリア

how to assign randomly generated numbers to a matrix say 10 by 2?

2 ビュー (過去 30 日間)
chan
chan 2015 年 9 月 29 日
コメント済み: chan 2015 年 9 月 29 日
i have created random numbers using the code k1=randi([1,1000],1,10) Now how to assign this 10 randomly generated numbers to a matrix 10 by 2 with repetition allowed.

採用された回答

Walter Roberson
Walter Roberson 2015 年 9 月 29 日
編集済み: Walter Roberson 2015 年 9 月 29 日
X = randi([1,1000],10, 1);
while true
M = [X, X(randperm(length(X)))];
if all(diff(M,2)~=0); break; end
end
The while loop removes the possibility that a number is matched with itself.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by