Trying to learn Rand - help get me started
2 views (last 30 days)
Show older comments
Hi, I'm trying to learn Matlab so I be more useful as an intern. Looking through the book I bought theres some practice - i have trouble with the following one, which is a "try this" problem and do they don't actually tell you how to do it:
Use an Array of characters 'A234567890JQK' to display a single random playing card. Hint: use a random number as an index value. Note that A = ace, 0 = 10, J = jack, Q = queen, and K = king. In oter words, your expression should randomly display a single character in the array.
So far I know how to put numbers in arrays, but characters? Can someone explain a way how to do so?
Thanks
0 Comments
Accepted Answer
the cyclist
on 8 Sep 2011
>> arrayOfAllCardRanks = 'A234567890JQK'
defines an array of characters, of size 1x13
I suggest using the randi() function for your next step, but won't give you the details.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!