How to loop rand number without repition?
이전 댓글 표시
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 ?
답변 (1개)
madhan ravi
2020년 9월 30일
doc randperm
댓글 수: 2
Muhammad Sam'an
2020년 9월 30일
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
카테고리
도움말 센터 및 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!