convert cell to integer

195 次查看(过去 30 天)
Zeynab Mousavikhamene
编辑: 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
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
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