How to loop rand number without repition?
12 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
madhan ravi
2020 年 9 月 30 日
doc randperm
2 件のコメント
Steven Lord
2020 年 10 月 1 日
"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
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!