Borrar filtros
Borrar filtros

uiopen “Error using handle.handle/get Invalid or deleted object.”

10 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Image Analyst
Image Analyst el 30 de Mzo. de 2015
I would never ever save the handles structure to a mat file. How do you know if the graphical handle ID numbers of the various GUI widget controls will have the same number the next time you run the program? Save only those variables that need saving. What I do is to create a global variable called UserSettings. It's a structure and you can attach any settings you want: variables, radio button settings, listbox settings, scroll bar settings, etc. - whatever you want. Then save just UserSettings, and then recall UserSetting the next time you run the program. Extract the scrollbar values, etc. and send those values to your GUI with the set() function.

Más respuestas (1)

Imed Elmottakel
Imed Elmottakel el 9 de Feb. de 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

Categorías

Más información sobre Geographic Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by