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

4 Ansichten (letzte 30 Tage)
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)))

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 2 Apr. 2014
Bearbeitet: Azzi Abdelmalek am 2 Apr. 2014
move = {'R' ,'P', 'S'}
cmove = move(randi(numel(move)))
or
move ='RPS'
cmove = move(randi(numel(move)))
  2 Kommentare
Giuseppe
Giuseppe am 2 Apr. 2014
is there a way to remove those quotation marks
Arjun P Kumar
Arjun P Kumar am 25 Sep. 2020
You can find them without quotation in the workspace

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by