# How do I convert a cell array whose dimensions are not equal?

4 ビュー (過去 30 日間)
Brad 2014 年 6 月 10 日
コメント済み: Geoff Hayes 2016 年 2 月 10 日
I have a cell array that looks like this:
mydata =
[10x11 double] [5x11 double]
Name Size Bytes Class Attributes
mydata 1x2 1544 cell
I'm trying to convert this to a numeric array using the cell2mat function. But I keep getting the following error message:
Error using cat Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 76) m{n} = cat(2,c{n,:})
Is it possible to convert a cell array whose dimensions are not equal?

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

### 採用された回答

Geoff Hayes 2014 年 6 月 10 日
Check out the documentation for cell2mat at http://www.mathworks.com/help/matlab/ref/cell2mat.html and in particular the example. In your case, the matrices have a different number of rows so cannot be concatenated in this way. But, if your cell array mydata was a column (rather than a row) with the same two elements, then yes it could be concatenated because each matrix has the same number of columns
mydata = cell(2,1);
mydata{1} = zeros(10,11);
mydata{2} = ones(5,11);
mtx = cell2mat(mydata);
##### 3 件のコメント1 件の古いコメントを表示1 件の古いコメントを非表示
Manoj 2016 年 2 月 10 日
It is showing an error
Error using cat Dimensions of matrices being concatenated are not consistent.
regards
Manoj Kumar Nellore
Geoff Hayes 2016 年 2 月 10 日
Manoj - what is showing an error? Presumably you are continuing this conversation at http://www.mathworks.com/matlabcentral/answers/267443-how-do-i-convert-a-cell-array-whose-dimensions-are-not-equal.

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

### カテゴリ

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