Azzera filtri
Azzera filtri

Cell contents reference from a non-cell array object error

3 visualizzazioni (ultimi 30 giorni)
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?

Risposte (1)

Jan
Jan il 10 Ago 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?

Categorie

Scopri di più su Data Type Identification in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by