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

3 ビュー (過去 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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by