uiopen “Error using handle.handle/get Invalid or deleted object.”
Show older comments
I'm a Matlab beginner with prior programming experience and have made a GUI that generates and plots data. As part of the GUI, I want to be able to save and load the data and so have created the following toolbar item callbacks:
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
If I save and load the data during the same session, everything works fine, but if I try to load the data in a new session, I get the following errors:
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
Furthermore, general use of the GUI seems to breakdown, for instance, clicking on a generate data button gives the errors:
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
Any assistance would be greatly appreciated!
Accepted Answer
More Answers (1)
Imed Elmottakel
on 9 Feb 2017
use global like this:
function vid_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
try
global cam vidRes nBands;
cam = webcam(1);
vidRes = cam.Resolution;
nBands = 3;
Temp = textscan(vidRes, '%s', 'delimiter','x');
vidRes = Temp{1};
global cam vidRes nBands hImage;
axes(handles.axes1);
if true
% code
end
hImage = image(zeros(str2num(vidRes{2}), str2num(vidRes{1}), nBands));
preview(cam, hImage);
catch E
msgbox({'Configure The Cam Correctly!',' ',E.message},'CAM INFO')
end
Categories
Find more on Scope Variables and Generate Names in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!