I would suggest a different approach. You could potentially have dozens of axes and just as many images in your app which could result in sluggish responses of the app. You'd also need to manage the uistack to ensure that various graphics objects are stacked in the correct order. It sounds like it could be a mess.
Are you stuck to using images? The cards could be simulated using text and rectangles within a single axes.
Here's a demo to get you started. At the end, I'll show how to work with these objects once they are plotted.
deck = ["A"; (2:10)';'J';'Q';'K'] + ["♥","♦","♠","♣"]
deck =
"A♥" "A♦" "A♠" "A♣"
"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♣"
"J♥" "J♦" "J♠" "J♣"
"Q♥" "Q♦" "Q♠" "Q♣"
"K♥" "K♦" "K♠" "K♣"
deckColors = repelem(["r","r","k","k"],height(deck),1)
deckColors =
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
"r" "r" "k" "k"
Specify number of cards in each stack
For simplicity, the number of cards are hard-coded in this demo.
Compute card size and position
cardWidth = ((1-2*gap)-(gap*(nStacks-1)))/nStacks;
xStack = gap:(cardWidth+gap):(1-gap);
cardHeight = 1.4286 * cardWidth;
Randomly select cards
This uses randperm to avoid duplicates
randIdx = randperm(numel(deck),sum(nCards));
randCards = deck(randIdx);
randCardColors = deckColors(randIdx);
Plot the cards in an axes
The demo creates a new figure and axes but you can replace this with your app's figure and axes handles.
fig = figure('Color',[0 .5 0]);
ax = axes(fig,'Position',[0 0 1 1]);
cardObjs = gobjects(1,sum(nCards));
yStack = (-gap-cardHeight) : -(yShift*cardHeight) : (-gap-cardHeight)-(nCards(i)*(yShift*cardHeight));
n = sum(nCards(1:(i-1)))+j;
cardObjs(n) = hggroup(ax);
cardPosition = [xStack(i), yStack(j), cardWidth, cardHeight];
rectangle('parent',cardObjs(n), ...
'Position', cardPosition, ...
text('parent',cardObjs(n), ...
'String', randCards(n), ...
'Color', randCardColors(n), ...
'Position', [cardPosition(1)+cardWidth/2, cardPosition(2)+cardHeight, 0],...
'HorizontalAlignment', 'Center', ...
'VerticalAlignment', 'top');
Now that some cards exist, you can work with them using their handles which are Group objects created by hggroup, stored in variable cardObjs. Each group contains a rectangle and text object. You can delete the k^th group using delete(cardObjs(k)).
Change the position of a card by updating the Position properties of each child of the group.
cardObjs(k).Children(1).Position
cardObjs(k).Children(2).Position
Since the cards will change position frequently, you could write a helper function to do this. You could also add a listener to the text object in each group so that it follows the rectangle. That way you'd only need to update the position of the rectange.
As you can probably imagine, there's a lot of flexibility here and with that, I'll hand it off to you. Good luck!