matlab R2020b randperm fuction is not random
Show older comments
Hi,
When I use matlab R2020b on linux platform, commands follow:
order = randperm(10)
disp(order)
results show:
6 3 7 8 5 1 2 4 9 10
6 3 7 8 5 1 2 4 9 10
Curiously, the result is fixed,i.e., when I run this script again, the same results appear. Does anybody know what's wrong? thanks
3 Comments
order = randperm(10)
order = randperm(10)
Doesn't look fixed to me.
See
for details on how to define the seed for the random generator (which can also be used to get different outputs if the script is executed several times (rng('shuffle'))).
Make sure you're using MATLAB's randperm function by using which
which randperm
Does the same result occur if you shuffle the random number generator?
randperm(10)
rng('shuffle')
randperm(10)
俊 马
on 19 Jul 2022
Accepted Answer
More Answers (0)
Categories
Find more on Share and Distribute Software in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!