how can I replace number cell array with character?

Hi guys,
I am trying to preapare a card game also I have created a deck that inclued 52 element and 13 diffrent value, my purpose creating a defined card array like Q instead of 12 in the 2x5 cell array.
image(2,5) = {''};
for upp=1:2
for app=1:5
chosen=BB(upp,app);
if chosen<36
image(upp,app)='Basic card';
elseif chosen<=40 && chosen>=36
image(upp,app)='A';
elseif chosen<=44 && chosen>=40
image(upp,app)='J';
elseif chosen<=48 && chosen>=40
image(upp,app)='Q';
elseif chosen<=52 && chosen>=48
image(upp,app)='K';
end
end
end
I have this error;
Conversion to cell from char is not possible.
thanks

 采纳的回答

image() is a built in function and you need to pass it a filename, not two scalars. Plus it belongs on the right side of an expression. You can't can't stuff an empty cell into the image function like you did, not to mention passing in two scalars to the image() function instead of a filename. So pick a different name, like caImage, for "cell array image". Then you need to use braces to assign the contents of the cell. See the FAQ: FAQ#What_is_a_cell_array? It will show you how/when/why to use braces, parentheses, and brackets.
caImage{upp, app} = 'Basic card';

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Convert Image Type 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by