Creating a function that does the same as myrandperm(n,k)
4 次查看(过去 30 天)
显示 更早的评论
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!