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

17 次查看(过去 30 天)
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.

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2015-7-27
编辑:Azzi Abdelmalek 2015-7-27
C={{1 3 4};{1 3 3}}
out=cell2mat(cellfun(@(x) cell2mat(x),C,'un',0))
  3 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2015-7-27
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 2015-7-27
Maybe your cell array looks like
C={{1 3 4};{1 3 3};[1 2 3]}
The third element is not a cell array

请先登录,再进行评论。

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by