Cell contents reference from a non-cell array object error

조회 수: 2 (최근 30일)
Aaron Smith
Aaron Smith 2017년 8월 2일
답변: Jan 2017년 8월 10일
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에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by