随机数的一个小小的想法。

老哥们好,我突然有个想法,就是用随机函数生成10组1-10的随机数,最后用100这个数来控制输出
a=randperm(10,10)
for i=1:100
    disp(a{1})
end
这代码可行么?

 Accepted Answer

vfypkcan
vfypkcan on 25 May 2023

0 votes

每组内的数值是否允许重复、如果允许重复那么每个数值的分布又是什么样的(最简单的自然是均匀分布),还是没有说明呀。
虽然其他人可以通过你的代码去猜"大约是不允许组内重复",但不能确保猜得准。提问时如果把这些都讲明的话,其他人就可以跳过猜测直接尝试解决问题了。

More Answers (0)

Categories

Find more on 随机数生成 in Help Center and File Exchange

Tags

Asked:

on 25 May 2023

Answered:

on 25 May 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!