Matlab script that randomly selects a card from a deck of 52

조회 수: 7 (최근 30일)
ENRIQUE SANCHEZ
ENRIQUE SANCHEZ 2016년 12월 2일
답변: Walter Roberson 2016년 12월 2일
I need to write a program using Matlab that randomly selects a single card(from a full deck 52 cards) and print the result out, i.e. ace-spades, 5-hearts, king-diamonds,etc. Thank you in advance

답변 (2개)

bio lim
bio lim 2016년 12월 2일
What have you done so far?
What you can do is first you define a cell array that contains each card of the deck. Then you can use randi to generate a random index into your cell array. Then, you can use print out the the card that belongs to the index.

Walter Roberson
Walter Roberson 2016년 12월 2일
randi(52)
Hint:
1 + mod((1:52)-1, 13)

카테고리

Help CenterFile Exchange에서 Simultaneous and Synchronized Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by