specified numbers of random permutation of a vector

27 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Elementary Math 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by