How to generate specific number of specific integers within a range?
1 次查看(过去 30 天)
显示 更早的评论
I want to generate a random array of 8 integers within [1,4] where each integer appears exactly twice. Examples:
1 1 2 2 3 3 4 4
4 2 1 2 3 1 3 4
2 4 1 2 3 4 3 1
I know randi(4,8,1) gives a random array of 8 integers within [1,4] but it does not specify how many come from which integer. Is there a built in matlab function that does this? If not, what should I do?
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!