Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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 comentarios
Angel
Angel el 5 de Oct. de 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 el 5 de Oct. de 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

Iniciar sesión para comentar.

Respuestas (1)

檮杌
檮杌 el 5 de Oct. de 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 comentarios
Angel
Angel el 6 de Oct. de 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!

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by