Problem using cell2mat

9 ビュー (過去 30 日間)
Alberto Paredes
Alberto Paredes 2021 年 10 月 15 日
コメント済み: DGM 2021 年 10 月 23 日
I have a 25 by 25 cell array. Each cell contains a 32 by 32 array of type double. When I use cell2mat MATLAB gives me the following error:
Error using cat
Dimensions of arrays being concatenated are not consistent.
Any ideas on how I can fix this issue?
I have MATLAB R2021a
  3 件のコメント
Alberto Paredes
Alberto Paredes 2021 年 10 月 22 日
編集済み: Alberto Paredes 2021 年 10 月 22 日
The data contained inside each 32 by 32 array was extracted from excel spreadsheets. Does this mean that one of these excel spreadsheets has an empty cell? If so is there a way to check for an empty cell in the excel spreadsheet as I import the data into my each element of my cell array?
DGM
DGM 2021 年 10 月 23 日
I don't know what the spreadsheets have. If there are missing rows/columns, then handling that on import depends on how they're being imported and where/why the rows/columns are missing.

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

回答 (1 件)

Sahil Jain
Sahil Jain 2021 年 10 月 18 日
Hi. As mentioned by another community member, "cell2mat" works without errors for the scenario you described. I used the following code to recreate your scenario with the same dimensions (similar to the code used by @DGM) .
A = rand(32,32,25*25);
B = num2cell(A, [1 2]);
B = reshape(B, [25 25]);
C = cell2mat(B);
size(C)
For troubleshooting, you can start by checking if all the cells are indeed 32x32 arrays.

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by