matlab Linux机房版2020Rb randperm函数不随机。

我在linux服务器上用matlab机房版2020Rb 的randperm函数:
order = randperm(10)
disp(order)
显示结果如下:
6 6 3 7 8 5 1 2 4 9 10
6 6 3 7 8 5 1 2 4 9 10
会出现两行,并且再一次执行randperm(10),也是上面的结果,请问有大神知道是怎么回事吗? 是不是缓存没清理?我提交的slurm的作业

 Accepted Answer

①你这连基础知识都没搞明白,去看 disp函数(超链接,自己点进去看) 帮助文档,在你代码里它相当于个复写纸,所显示的两行内容如果不一样才奇怪了
②执行前自己用 rng函数(超链接,自己点进去看) 改种子值,如果不同种子值仍然返回上述序列,那就是你的 randperm 出问题了

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!