我是一名具有先前编程经验的Matlab初学者,并制作了一个生成和绘制数据的GUI。作为GUI的一部分,我希望能够保存和加载数据,因此创建了以下工具栏项回调:
function save_ClickedCallback(hObject, eventdata, handles)
uisave('handles');
.......
function open_ClickedCallback(hObject, eventdata, handles)
uiopen('*.mat');
guidata(hObject, handles);
updatePlot(handles); %updates the GUI's plots
set(handles.opt,'Value',handles.optValue); %updates some displayed parameters
set(handles.nsimu,'String',handles.nsimuString); %updates some displayed parameters
如果我在同一会话期间保存并加载数据,一切正常,但如果我尝试在新会话中加载数据,则会出现以下错误:
Error using handle.handle/get
Invalid or deleted object.
Error in MonteCarloKAGRA_GUI>updatePlot (line 79)
subplot(get(handles.noise, 'Value')+get(handles.convergence, 'Value')+1,1,1,'Parent',handles.plotArea);
Error in MonteCarloKAGRA_GUI>open_ClickedCallback (line 485)
updatePlot(handles);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in MonteCarloKAGRA_GUI (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)MonteCarloKAGRA_GUI('open_ClickedCallback',hObject,eventdata,guidata(hObject))
Error while evaluating uipushtool ClickedCallback
此外,GUI的一般使用似乎已经崩溃,例如,单击生成数据按钮会出现错误:
Error using handle.handle/get
Invalid or deleted object.
Error in MonteCarloKAGRA_GUI>generate_Callback (line 213)
str=get(handles.opt,'String');
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in MonteCarloKAGRA_GUI (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)MonteCarloKAGRA_GUI('generate_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
非常感谢任何帮助!