How to convert a cell array of cell arrays to matrix ?

7 Ansichten (letzte 30 Tage)
j john
j john am 27 Jul. 2015
Beantwortet: Abhinuv Pitale am 12 Sep. 2018
I need to convert a cell array of cell arrays to matrix. I tried to use cell2mat() , but I am getting an error message.
C={{1 3 4};{1 3 3}}
C =
{1x3 cell}
{1x3 cell}
cell2mat(C)
Error using cell2mat (line 53)
Cannot support cell arrays containing cell arrays or objects.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 27 Jul. 2015
Bearbeitet: Azzi Abdelmalek am 27 Jul. 2015
C={{1 3 4};{1 3 3}}
out=cell2mat(cellfun(@(x) cell2mat(x),C,'un',0))
  3 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 27 Jul. 2015
This has nothing to do with the fact that tour cell array is bigger. Your example is not representative of your data. Please give more details about your cells.
Azzi Abdelmalek
Azzi Abdelmalek am 27 Jul. 2015
Maybe your cell array looks like
C={{1 3 4};{1 3 3};[1 2 3]}
The third element is not a cell array

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Abhinuv Pitale
Abhinuv Pitale am 12 Sep. 2018
With different type of objects in the array, you cant use the lambda as suggested above!

Kategorien

Mehr zu Cell Arrays 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