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

5 ビュー (過去 30 日間)
j john
j john 2015 年 7 月 27 日
回答済み: Abhinuv Pitale 2018 年 9 月 12 日
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 Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by