How to pick random number?
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, Please forgive me if I am asking a basic question. I want to pick random number from the set {2,3}. It should either pick 2 or 3 randomly. I have been looking at these functions called 'rand', 'randi', 'randperm' etc., but i couldn't figure out how to use them for my problem. Any help would be appreciated.
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 10월 2일
편집: Azzi Abdelmalek
2013년 10월 2일
randi([2 3])
%or
v=[2 3];
v(randi(2))
댓글 수: 3
추가 답변 (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!