MATLAB Answers

Matlab cell2mat error

20 views (last 30 days)
Hi,
I have a following error when I use Matlab 2012b and 2016a. "Error using cell2mat (line 52) CELL2MAT does not support cell arrays containing cell arrays or objects." However, I do not have this error in Matlab 2014a. Does anyone have idea why this happens?
Thank you
  5 Comments
Ahmed Ali
Ahmed Ali on 4 Jul 2019
Good evening
I can not help you
Thank you very much
ffff.JPG
Undefined variable "xldata" or class "xldata.treat".
Error in main_disease_classification (line 21)
treat = uipanel.cell2mat(xldata.treat);

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 12 Jan 2017
Edited: Walter Roberson on 12 Jan 2017
I had to make a lot of changes to the code. I made the first batch of fixes against R2014a; I marked those in the code with 'WDR'. I then moved over to a new release and fixed the cell2mat problems that you had posted about; those are also marked with 'WDR' in the code.
For example, the code assumes that some ultrasound information is present in the dicom information; I removed that limitation. Also, I removed the assumption that the ocr() routine is available (it requires a new-ish version of the Computer Vision toolbox.)
From R2014b onwards, the colormap changing did not work, because colormaps now depend on the axes. I fixed that.
From R2014b onwards, the majority of the callbacks that you had defined failed. You have them defined as methods of VUESR so they were marked as belonging only to VUESR objects. However, graphics callback get invoked with graphics objects as the first parameter, and the way MATLAB determines which object a routine is to be looked up against in a call is by scanning for the first object from the left in the parameter list. Therefore for normal graphics callbacks, you need routines that are either outside of any class, or are derived from the graphics system. The fix was to move "tool" to be the first parameter of all of the graphics callbacks (including adding it as a parameter to a couple of routines it was not passed to before) and adjusting the calling sequence of all of the callback anonymous functions to insert tool as the first parameter. This was a fair bit of editing, and I did not mark the changes.
After that I did more testing and fixed some bugs, mostly relating to the assumption that there were multiple images available.
  3 Comments
Walter Roberson
Walter Roberson on 12 Jan 2017
... emailed.

Sign in to comment.

More Answers (2)

Abhinav Gurram
Abhinav Gurram on 11 Nov 2016
It might very well be possible that the data you are trying to convert is not supported by the cell2mat function. cell2mat takes as input a cell array, in which all cells contain the same data type. The input cell array can contain numeric or character data within cells, or structures with the same field names and data types. However, cell2mat currently does not, nor has it ever accepted objects or nested cells within the input cell array. If your cell array contains objects or nested cells, this could be a possible reason for why you are seeing the error.
However, if your data is not in the form of objects or nested cells, it would be helpful if you can provide a sample of code that will help us reproduce this issue. I'm particularly interested to know why the code fails on R2012a and R2016a versions of MATLAB, but works fine on R2014a.
Cheers!
  1 Comment
Walter Roberson
Walter Roberson on 12 Jan 2017
The code was creating a cell array each member of which is a uipanel object. cell2mat refuses to work with objects because objects cannot in general be concatenated. Potentially cell2mat could be enhanced to check ishghandle and allow the cell2mat in that case.

Sign in to comment.


Dae Woo Park
Dae Woo Park on 12 Jan 2017
Edited: Dae Woo Park on 12 Jan 2017
Thank you for your kind help. Could you mail me (<mailto:bigrain@umich.edu bigrain@umich.edu>) or attach here your revised code?
Regards
Dae Woo

Community Treasure Hunt

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

Start Hunting!