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

1 Ansicht (letzte 30 Tage)
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 Kommentare
Angel
Angel am 5 Okt. 2023
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 am 5 Okt. 2023
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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

檮杌
檮杌 am 5 Okt. 2023
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 Kommentare
Angel
Angel am 6 Okt. 2023
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!

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by