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 Analyst
Image Analyst 2020년 5월 3일
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에 대해 자세히 알아보기

태그

질문:

2020년 5월 3일

댓글:

2020년 5월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by