Trying to learn Rand - help get me started

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

the cyclist
the cyclist il 8 Set 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.

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by