CELL2MAT does not support cell arrays containing cell arrays or objects.

hello guys.Can you understand Chinese?The sentence in blue means that "CELL2MAT does not support cell arrays containing cell arrays or objects".I never see any error like this.I translated it into English by Google Translator.So it may be not accurate.Do anyone experience this error.Could you please tell me how to do?By the way,my MATLAB version is R2019b,the code is earlier.So i think whether the old version and the new version are incompatible.I think the code itself don't have grammatical errors.Thank you for your answer!

12 Comments

The error is diagnosed by Simulink.The code attach to the modules.CELL2MAT is in "IEEE80211a_graphics.m" If you need more information I can send you all the files to you personally.
The problem appears to be at line 11
haxes = cell2mat(struct2cell(ax));
I would not have expected that line to ever work. It is wrong in multiple ways.
Replacement code:
if isstruct(ax)
ax_cell = struct2cell(ax);
haxes = vertcat(ax_cell{:});
else
haxes = ax;
end
it just has a new error. it means"Non-scalar arrays of function handles are not allowed; use cell arrays instead."how could i do?
AND the error happens just when i open a figure file.if i don't open it the error won't happen.
Put in a line of code that asks it to celldisp(ax_cell) and show us the results
like this?
but it also has an error.
No, I mean like
if isstruct(ax)
ax_cell = struct2cell(ax);
cell_disp(ax_cell);
haxes = vertcat(ax_cell{:});
else
haxes = ax;
end
This is not expected to fix the problem: this is expected to display output that you will copy and paste here and that will help me diagnose the problem.
I followed it.It shows the property of ax_cell.
Hello,i can't solve it until now.I think I don't have enough capicity to
cope with it,Could you please help me?All codes are aviliable except only one error I mentioned.All codes are attached.Only I opened,It happened an error.Hope your help.Thank you.
That model was designed for MATLAB R13SP1, which was from 2003. It is not surprising that it does not work in current releases.

Sign in to comment.

Answers (1)

Indeed cell2mat does not support converting a cell array containing objects into a matrix. It looks like your cell array contains axes handles. Prior to R2014b axes handles used to be plain numbers so indeed you could convert a cell array of axes handles to a matrix. From R2014b, axes handles are objects and the error would appear.
Without knowing the exact details of what is in your cell array (shape and size) it's not easy to tell you how to solve the problem. Hence why Walter asked you to run the celldisp, so we could see what's in there.
Assuming that each cell contains a single axes handle, or row vectors of axes handles, then:
axes_mat = [ax_cell{:}];
If the cells contain column vectors/of axes handles:
axes_mat = vertcat(ax_cell{:});
If they contain 2D or ND matrix, it will be more complicated.
edit: following the output of celldisp being shown:
Since the cell array contains scalar axes handles, any of the above would work.

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2019b

Asked:

on 22 Feb 2020

Commented:

on 9 Mar 2020

Community Treasure Hunt

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

Start Hunting!