specified numbers of random permutation of a vector

27 Ansichten (letzte 30 Tage)
mehdi J
mehdi J am 1 Jan. 2019
Beantwortet: mehdi J am 1 Jan. 2019
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 Kommentar
Walter Roberson
Walter Roberson am 1 Jan. 2019
Duplicates https://www.mathworks.com/matlabcentral/answers/437825-how-could-i-find-specified-number-of-permutation-of-a-vector

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Weitere Antworten (3)

madhan ravi
madhan ravi am 1 Jan. 2019
Bearbeitet: madhan ravi am 1 Jan. 2019
Perhaps random indexing like below?
vector(randperm(100)) % 100 a specified number

Stephen23
Stephen23 am 1 Jan. 2019
Where V is your vector:
idx = randperm(n);
V(idx(1:100))

Walter Roberson
Walter Roberson am 1 Jan. 2019

Kategorien

Mehr zu Elementary Math finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by