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

3 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)))
or
move ='RPS'
cmove = move(randi(numel(move)))

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!