specified numbers of random permutation of a vector

9 ビュー (過去 30 日間)
mehdi J
mehdi J 2019 年 1 月 1 日
回答済み: mehdi J 2019 年 1 月 1 日
randperm(n) returns a row vector containing a random permutation of the integers from 1 to n inclusive but I need random permutation of the integers from a vector, also I don't need all off them just specified number e.g. 100.
  1 件のコメント
Walter Roberson
Walter Roberson 2019 年 1 月 1 日
Duplicates https://www.mathworks.com/matlabcentral/answers/437825-how-could-i-find-specified-number-of-permutation-of-a-vector

サインインしてコメントする。

採用された回答

mehdi J
mehdi J 2019 年 1 月 1 日
I did it by myself as below:
for k=1:MatSize
ind=randperm(numel(vec));
Mat(k,:)=vec(ind);
end

その他の回答 (3 件)

madhan ravi
madhan ravi 2019 年 1 月 1 日
編集済み: madhan ravi 2019 年 1 月 1 日
Perhaps random indexing like below?
vector(randperm(100)) % 100 a specified number

Stephen23
Stephen23 2019 年 1 月 1 日
Where V is your vector:
idx = randperm(n);
V(idx(1:100))

Walter Roberson
Walter Roberson 2019 年 1 月 1 日

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by