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

3 vues (au cours des 30 derniers jours)
Giuseppe
Giuseppe le 2 Avr 2014
Commenté : Arjun P Kumar le 25 Sep 2020
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)))

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by