How do I change cell array to matrix?

This question has been asked several times but none of the answers have helped me so far.
I have a cell array, C, that is 5 x 6 with each cell being 1 x 1.
How do I get a resulting 5 x 6 matrix with all indices being treated as numbers? I have used cell2mat(C) but that just results in the error 'Dimensions of matrices being concatenated are not consistent.' Shouldn't this work since each cell is 1 x 1?

3 件のコメント

Stephen23
Stephen23 2018 年 5 月 10 日
@K: please upload your cell array in a .mat file, by clicking the paperclip button.
Star Strider
Star Strider 2018 年 5 月 10 日
‘Shouldn't this work since each cell is 1 x 1?’
No.
Consider:
C = {{rand(2)}, {rand(3)}}
C =
1×2 cell array
{1×1 cell} {1×1 cell}
K
K 2018 年 5 月 10 日
The actual cell array is much larger. But I attached it..

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

 採用された回答

Star Strider
Star Strider 2018 年 5 月 10 日

0 投票

The numbers are stored as character arrays, the reason the dimensions did not match.
Simply convert them to a numeric array:
N = str2double(A1)

2 件のコメント

K
K 2018 年 5 月 10 日
Thank you!
Star Strider
Star Strider 2018 年 5 月 10 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2016b

質問済み:

K
K
2018 年 5 月 10 日

コメント済み:

2018 年 5 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by