Cell contents reference from a non-cell array object error

1 次查看(过去 30 天)
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?

回答(1 个)

Jan
Jan 2017-8-10
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?

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by