How to loop rand number without repition?
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I Have
set phi = [ 1,2,3,4,5,6,7,8,9,10,11,12]
i want rand phi with looping with requirment for each iteration resulted single rand number without repitition?
How should i do ?
0 Commenti
Risposte (1)
madhan ravi
il 30 Set 2020
doc randperm
2 Commenti
Steven Lord
il 1 Ott 2020
"Shuffle" the vector before you enter the loop. Inside the loop draw the next element of the vector that you haven't used yet.
r = randperm(52);
for k = 1:5
fprintf("Drawing card %d.\n", r(k))
end
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!