Randomly picking between two variables
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, I have three variables, BoxA and BoxB. Where BoxA=1, BoxB=2. I would like it so that if I can pick randomly between BoxB and BoxC. Thank you.
댓글 수: 0
답변 (1개)
Walter Roberson
2011년 5월 9일
What is BoxC ??
Anyhow, to pick N by M random values from a list:
rvals = [BoxA, BoxB]; %expand the list if you have reason
randompicks = rvals(ceil(rand(N, M) * length(rvals)));
I believe there is also a Stats toolbox function to do random sampling of exactly this kind.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!