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

25 views (last 30 days)
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)))

Accepted Answer

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

More Answers (0)


Find more on Characters and Strings in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by