フィルターのクリア

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

2 ビュー (過去 30 日間)
Angel
Angel 2023 年 10 月 4 日
コメント済み: Voss 2023 年 10 月 6 日
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!
Voss
Voss 2023 年 10 月 6 日
@Angel: Don't forget to click "Accept" on @檮杌's answer.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by