how to find random number between 20 input numbers
1 次查看(过去 30 天)
显示 更早的评论
I have 20 numbers that I want to find 1 or 2 or 3 of them as random. Could you help me to write code or any function that generate random number?
0 个评论
采纳的回答
Walter Roberson
2017-11-19
L = length(YourVectorOfNumbers);
num_to_pick = randi(3);
which_to_pick = randperm(L, num_to_pick);
picked_values = YourVectorOfNumbers(which_to_pick);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!