Azzera filtri
Azzera filtri

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

3 visualizzazioni (ultimi 30 giorni)
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)))

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 2 Apr 2014
Modificato: Azzi Abdelmalek il 2 Apr 2014
move = {'R' ,'P', 'S'}
cmove = move(randi(numel(move)))
or
move ='RPS'
cmove = move(randi(numel(move)))

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by