Cell2mat input cell array error

I have this error:
Error using cell2mat (line 46) All contents of the input cell array must be of the same data type.
When I check input cell array, it is all numbers or empty cells. I replaced it for only one column with only numbers and still same problem. Does anyone have any idea of what it could be?
Thanks

4 件のコメント

David Sanchez
David Sanchez 2013 年 8 月 12 日
Are you saying that the following code yields an error?
X = rand(10,1);
my_cell = mat2cell(X)
If Yes, you have a problem with your machine.
If No, could you paste the code you are using, please?
David Sanchez
David Sanchez 2013 年 8 月 12 日
Code to test ( I forgot last line ):
X = rand(10,1);
my_cell = mat2cell(X)
XX = cell2mat(my_cell);
Iman Ansari
Iman Ansari 2013 年 8 月 12 日
A={[1 2],uint8([3 4])};
cell2mat(A)
Error using cell2mat (line 46)
All contents of the input cell array must be of the same data type.
Diana
Diana 2013 年 8 月 13 日
thank you! It helped me a lot!

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

 採用された回答

Image Analyst
Image Analyst 2013 年 8 月 12 日

0 投票

Are you sure that all cells could be extracted to form a solid 2D matrix with no "missing" elements? You can't ask it to have one row with 10 elements and the row below it to have 7 elements. Those empty cells could be causing your problem.

1 件のコメント

Image Analyst
Image Analyst 2013 年 8 月 12 日
Make [1 2] uint8 also. Or else make [3 4] double. If you're using integers, they must match exactly with other integers of the same class (uint8 or uint16 or int32).

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by