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

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)))

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 2 de Abr. de 2014
Editada: Azzi Abdelmalek el 2 de Abr. de 2014
move = {'R' ,'P', 'S'}
cmove = move(randi(numel(move)))
or
move ='RPS'
cmove = move(randi(numel(move)))

2 comentarios

is there a way to remove those quotation marks
You can find them without quotation in the workspace

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 2 de Abr. de 2014

Comentada:

el 25 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by