MATLAB: GUI error: Struct contents reference from a non-struct array object. Happens in OutputFcn

guiguide

This is my first GUI program in MATLAB and I'm not sure I'm exiting the gui correctly. I call my GUIDE created GUI program with
test=LightPeakGUI(timedat);
where timedat is a 1×3 cell array. My OpeningFcn looks this this:
function LightPeakGUI_OpeningFcn(hObject, eventdata, handles, varargin)
%set the temp data to the first cell of the timedat arguement
handles.tempall=varargin;
handles.temp=handles.tempall{1}{1};
handles.currentpt=1;
ind=~isnan(handles.temp(:,1));
handles.current_data=handles.temp(ind,:);
handles.deleted=cell(1,length(handles.tempall{1}));
handles.particlecount=1;
scatter(handles.current_data(handles.currentpt+1:end,1),handles.current_data(handles.currentpt+1:end,2),'k');
hold on;
scatter(handles.current_data(handles.currentpt,1),handles.current_data(handles.currentpt,2),'r');
handles.output = hObject;
guidata(hObject, handles);
uiwait(handles.figure1);
end
I have a few push buttons that do various things and an OutputFcn that looks like:
function varargout = LightPeakGUI_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
end
When I close the GUI by clicking on the "x" in the upper right corner, it throws the error that is mentioned in the subject line of the question. I tried some other things, like setting my handles.output variable equal to handles.tempall{1} (which is what I really wanted to do), but I got the same error. Any ideas what's going on?
Thanks.

Best Answer