MATLAB: Error at fprintf: function not defined for ‘cell’ inputs

cellarrayfprintf

Can someone tell me what's wrong?
clear;
count=0;
suit={'clubs' 'diamonds' 'hearts' 'spades'};
for i =1:4
for j= 1:13
count = count + 1;
cards(count).suit = suit(i);
cards(count).number = j;
end;
end;
disp('A new deck is ready');
cCont = 'y';
while (cCont=='y');
if ((length(cards))>5)
[hand, newcards] = extractHand(cards);
cards=newcards;
fprintf('\n Your hand is: \n');
for i = 1:4
fprintf(' %s %d -', hand(i).suit, hand(i).number);
end;
fprintf(' %s %d ', hand(5).suit, hand(5).number);
cCont=input('Do you want to continue(y/n)?','s');
else
disp('Sorry, no more hands in the deck');
cCont='n';
end;
end;
It gives me thar error: Error using fprintf Function is not defined for 'cell' inputs.
fprintf(' %s %d -', hand(i).suit, hand(i).number);

Best Answer

Change
cards(count).suit = suit(i);
to
cards(count).suit = suit{i};
Related Question