Shuffling and Using a Set of Six 52-Card Decks

1 回表示 (過去 30 日間)
Ryan Bingaman
Ryan Bingaman 2019 年 8 月 9 日
編集済み: Ryan Bingaman 2019 年 8 月 9 日
Hello,
In my current project, the goal is to create a vector of a randomized "playing card" matrix to implment into my code. I was wondering on how I could create a vector which would be a randomied version of the original "decksofcards" vector using the same numbers without repitition. Thank you!
This is what I have so far.
cardpack = [2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11 11 11 11];
decksofcards = repmat(cardpack,1,6);
randomcards = randperm(312);
for q = 1:length(deckofcards)
shuffledcard(q) = randomcards(q);
end

回答 (1 件)

James Tursa
James Tursa 2019 年 8 月 9 日
編集済み: James Tursa 2019 年 8 月 9 日
It is not entirely clear what you want. Maybe this instead of the loop?
shuffledcard = decksofcards(randomcards);
  1 件のコメント
Ryan Bingaman
Ryan Bingaman 2019 年 8 月 9 日
編集済み: Ryan Bingaman 2019 年 8 月 9 日
My apologies for the confusion but this is exactly what I needed.
Thank you!

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

カテゴリ

Help Center および File ExchangeDesktop についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by