Creating a function that does the same as myrandperm(n,k)
1 回表示 (過去 30 日間)
古いコメントを表示
Furkan Karaman
2020 年 11 月 12 日
コメント済み: Furkan Karaman
2020 年 11 月 19 日
I have to create a function,which does the same as myrandperm(n,k). I thought of creating a for loop which goes from 1 to k in which an array p(i) gets initialised by a random integer of an array n. And then p(i) gets deleted from from the array n.
But I didnt found a function that gives me a random integer from an array.
Do you guys have any ideas?
0 件のコメント
採用された回答
Walter Roberson
2020 年 11 月 12 日
randi(length(n))
4 件のコメント
Walter Roberson
2020 年 11 月 19 日
random index = randi(length(d))
random value = d(random index)
delete entry "random index" from d
lathe, rinse, repeat
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!