convert cell to integer

조회 수: 286 (최근 30일)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 8월 16일
편집: Adam Danz 2019년 8월 16일
I have a 1*1 cell in which its content is ineger. I need to convert the content to integer (no cell anymore just like a number itself)
how can I do that?
I tied cell2mat but did not work. It is like this now:
kar =
1×1 cell array
{[3]}
  댓글 수: 3
madhan ravi
madhan ravi 2019년 8월 16일
whos kar % Paste the results from command window here
Adam Danz
Adam Danz 2019년 8월 16일
편집: Adam Danz 2019년 8월 16일
While you're at it, let us know what this returns or if it returns an error, too.
class(kar{:})
size(kar{:})

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2019년 8월 16일
If ‘kar’ is initially:
kar = {{[3]}};
try this:
n = cell2mat(kar{:})
producing:
n =
3
  댓글 수: 2
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 8월 16일
I get this error:
>> cell2mat(kar{:})
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 36)
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 8월 16일
Initially kar is :
kar =
1×1 cell array
{[3]}

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by