convert cell to integer

195 Ansichten (letzte 30 Tage)
Zeynab Mousavikhamene
Zeynab Mousavikhamene am 16 Aug. 2019
Bearbeitet: Adam Danz am 16 Aug. 2019
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 Kommentare
madhan ravi
madhan ravi am 16 Aug. 2019
whos kar % Paste the results from command window here
Adam Danz
Adam Danz am 16 Aug. 2019
Bearbeitet: Adam Danz am 16 Aug. 2019
While you're at it, let us know what this returns or if it returns an error, too.
class(kar{:})
size(kar{:})

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 16 Aug. 2019
If ‘kar’ is initially:
kar = {{[3]}};
try this:
n = cell2mat(kar{:})
producing:
n =
3
  2 Kommentare
Zeynab Mousavikhamene
Zeynab Mousavikhamene am 16 Aug. 2019
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 am 16 Aug. 2019
Initially kar is :
kar =
1×1 cell array
{[3]}

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by