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 件のコメント

Adam Danz
Adam Danz 2019 年 8 月 16 日
編集済み: Adam Danz 2019 年 8 月 16 日
"I tried cell2mat but it did not work"
What does that mean? Did you get an error? If so, what was the full error message? If your example accurately describes your data, it should work.
kar = {[3]};
cell2mat(kar)
% ans =
% 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 日

2 投票

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]}

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

質問済み:

2019 年 8 月 16 日

編集済み:

2019 年 8 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by