Generating random integers in MATLab
3 次查看(过去 30 天)
显示 更早的评论
Can anyone please tell me on how to generate random inters every time my program passes through the loop.
I need 20 nodes between the coordinates of 0-100
during each iterations 20 nodes have to be created at random coordinates.
0 个评论
采纳的回答
madhan ravi
2018-12-25
randi([0 100],1,20)
2 个评论
John D'Errico
2018-12-25
+1, but remember that this generates integers with replacement. So if you cannot tolerate replicates, then you need to use other tools. Randperm can do it without replacement, so if you want them including 0 up to 100, do this:
randperm(101,20) - 1
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!