How can I sort a vector in a random manner in MATLAB?
조회 수: 70 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2011년 6월 29일
편집: Dyuman Joshi
2020년 11월 25일
I have a 1-dimensional array and would like to sort the elements of this vector randomly.
채택된 답변
MathWorks Support Team
2011년 6월 29일
To sort the elements of a vector randomly you can use the RANDPERM() function.
RANDPERM(n) returns a random permutation of the integers 1:n.
a = [1 2 3 4 5];
a_rand = a(randperm(length(a)));
댓글 수: 2
Dyuman Joshi
2020년 11월 25일
편집: Dyuman Joshi
2020년 11월 25일
How to obtain all possible random permutations of an given array?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!