function [next_cardnum, next_suit] = ...
  ProbComb5CardGameNextCardExclude(excludenums, excludesuits, cardnum, suit)
% [next_cardnum, next_suit] = ProbComb5CardGameNextCardExclude(cardnum, suit, excludenums, excludesuits)
% Find next card in 5-card game (5 #'s, 4 suits) while excluding certain cards.
% If past end of deck, set card # and suit to 0's.

  
  % Loop until valid next card found or end of deck reached.
  next_card_found = 0
  loopcnt = 0;
  
  while next_card_found == 0
    % Get next card.
    [next_cardnum, next_suit] = ProbComb5CardGameNextCard(cardnum, suit)
    
    % Check if at end of deck
    if next_cardnum == 6
      % Past end of card deck.  Set card # and suit to indicate error.
      next_cardnum = 0;
      next_suit = 0;
      % Done, so return to calling program.
      return
    end
    
    % Check if card is in exclude list.
    a1 = next_cardnum' == excludenums'
    a2 = next_suit' == excludesuits'
    a3 = and(next_cardnum' == excludenums', next_suit' == excludesuits')
    a4 = any(and(next_cardnum' == excludenums', next_suit' == excludesuits'))
    a5 = not(any(and(next_cardnum' == excludenums', next_suit' == excludesuits')))
    if not(any(and(next_cardnum' == excludenums', next_suit' == excludesuits')))
      next_card_found = 1;
    else
      cardnum = next_cardnum;
      suit = next_suit;
    end
    loopcnt = loopcnt + 1
    if loopcnt > 5
      break
    end
  end
end

