Trying to learn Rand - help get me started

1 次查看(过去 30 天)
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

采纳的回答

the cyclist
the cyclist 2011-9-8
>> 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 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by