필터 지우기
필터 지우기

How can i plot both hands in a way that shows me the probabilities related to pulling cards?

조회 수: 2 (최근 30일)
fullDeck = ["AS",'2S','3S','4S','5S','6S','7S','8S','9S','10S','JS','QS','KS','AH','2H','3H','4H','5H','6H','7H','8H','9H','10H','JH','QH','KH','AD','2D','3D','4D','5D','6D','7D','8D','9D','10D','JD','QD','KD','AC','2C','3C','4C','5C','6C','7C','8C','9C','10C','JC','QC','KC',]
matlabHand = []
personalHand = []
for i = 1:1000
idx = randi([1 52], 1)
matlabHand = [fullDeck(idx); matlabHand]
end
for i = 1:30
idx = randi([1 52], 1)
personalHand = [fullDeck(idx); personalHand]
end
  댓글 수: 4
Angel
Angel 2023년 10월 5일
I'm thinking of a scatter plot where my X are the 52 cards and my Y is the number of times they show up in my hand
Angel
Angel 2023년 10월 5일
I understand that I am pulling multiple cards with the same suit and rank. In this experimant, im pulling from a random stream of cards

댓글을 달려면 로그인하십시오.

답변 (1개)

檮杌
檮杌 2023년 10월 5일
Would this work for you?
numbering = ["A",string(2:10), "J", "Q", "K"];
shape = ["S"; "H"; "D"; "C"];
fullDeck = reshape(transpose(numbering + shape), 1, []);
% random sampling with replacement
matlabHand = randi(52, 1, 1000);
personalHand = randi(52, 1, 30);
C1 = hist(matlabHand, 1:52);
C2 = hist(personalHand, 1:52);
%%
figure('position', [500, 500, 1200, 500]);
subplot(2, 1, 1);
scatter(1:52, C1, 30, 'filled')
xticks(1:52)
xticklabels(fullDeck)
xlim([0, 53]);
ylim([0, max(C1)])
ylabel('Frequency');
xlabel('Deck Names');
grid on;
title('MATLAB hand')
subplot(2, 1, 2);
scatter(1:52, C2, 30, 'filled')
xticks(1:52)
xticklabels(fullDeck)
xlim([0, 53]);
ylim([0, max(C1)])
ylabel('Frequency');
xlabel('Deck Names');
grid on;
title('personal hand')
  댓글 수: 2
Angel
Angel 2023년 10월 6일
This is perfect, I changed the ylim on the personal hand to make the y distribution easier to see with the Matlab hand. Thank you!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by