필터 지우기
필터 지우기

specified numbers of random permutation of a vector

조회 수: 21 (최근 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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by