Cell contents reference from a non-cell array object error

1 visualización (últimos 30 días)
Aaron Smith
Aaron Smith el 2 de Ag. de 2017
Respondida: Jan el 10 de Ag. de 2017
I have a code for selecting regions of interest on an image, create a mask and then apply this mask to the matrices in a cell array. The problem that is occurring is that Matlab says the cell contents reference a non-cell array object.
Cell contents reference from a non-cell array object.
Error in hopefully_the_last_window>pushbutton3_Callback (line 191)
Y = X{i}.*mask;
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in hopefully_the_last_window (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)hopefully_the_last_window('pushbutton3_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I read on another answer on Mathworks that changing the {} brackets in my code to standard brackets () would fix this error ( changing Y = X{i}.*mask to Y = X(i).*mask). When I did this Matlab simply froze and stopped responding. Is this fix a decent solution to the error with some tweaks to stop matlab freezing or is there another possible cause of the error than the bracket?

Respuestas (1)

Jan
Jan el 10 de Ag. de 2017
Look at the code:
X = handles.finishCell;
mask = labeledImage;
for i = 1 : numel(X)
Y = X{i}.*mask;
end
We cannot know, what the contents of "handles.finishCell" is. The error message tells clearly, that it is not a cell array. Then simply using round parenthesis is pure guessing. You have to find out, what the contents of this variable is. Do not apply a solution, which was posted for perhaps a completely different problem.
Note that Y is overwritten in each iteration. Perhaps you want Y{i} also. Then some lines later:
handles.X = Y{i};
Are you sure, that you want the last element of Y only?

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by