How to select a one random letter from a matrix of letters.

조회 수: 4 (최근 30일)
Giuseppe
Giuseppe 2014년 4월 2일
댓글: Arjun P Kumar 2020년 9월 25일
I have the array.
move = [R ,P, S]
How would I select a random letter from this array.
cmove = ?
Would it look something like this ?:
cmove = move(rand(numel(move)))

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 2일
편집: Azzi Abdelmalek 2014년 4월 2일
move = {'R' ,'P', 'S'}
cmove = move(randi(numel(move)))
or
move ='RPS'
cmove = move(randi(numel(move)))
  댓글 수: 2
Giuseppe
Giuseppe 2014년 4월 2일
is there a way to remove those quotation marks
Arjun P Kumar
Arjun P Kumar 2020년 9월 25일
You can find them without quotation in the workspace

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by