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!