How to randomly generate an integer which is unique during multiple iterations
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
pavikirthi
am 27 Okt. 2015
Kommentiert: pavikirthi
am 27 Okt. 2015
How to generate a random integer in the range of 1 to 100 uniquely when the program is run and which undergoes multiple iterations? When I am using randi as follows, it is generating integer randomly but at times its not unique when the program is run in multiple iterations
index{i} = randi([1 100],1,1);
0 Kommentare
Akzeptierte Antwort
Jos (10584)
am 27 Okt. 2015
You can use the function randperm for this:
N = 10
R = randperm(N)
for k=1:N
Current_Random_Integer = R(k)
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!