Error Using GUI after first time - "Error using handle.handle/set Invalid or deleted object."
Show older comments
I'm a beginner in guide and I'm doing something simple where I load (pushbutton) data and when I'm finished the first time it saves the number of files I loaded. Without closing the GUI I try to load again but I get this error message:
Error using handle.handle/set Invalid or deleted object.
Error in wrg_calc_01>loadbut_Callback (line 92) set(handles.nfiles,'String', str1)
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in wrg_calc_01 (line 43) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)wrg_calc_01('loadbut_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
------------\\-------------
The code where that this is referring to is the following:
% --- Executes on button press in loadbut.
function loadbut_Callback(hObject, eventdata, handles)
% hObject handle to loadbut (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%Select the files
[filesnames, pathname] = uigetfile({'*.wrg'},'Pick a file', 'MultiSelect', 'on');
if ischar(filesnames)==0
nfiles=length(filesnames);
str=char('Number of files selected: %d');
str1=sprintf(str,nfiles);
%sets the name presented in GUI as the path
set(handles.staload, 'String', pathname)
*set(handles.nfiles,'String', str1) %String that changes* whenever i change the number of files loaded
for i=length(filesnames):-1:1
data=fullfile(pathname, filesnames(i)); %complete path, cell type
data=char(data); %Change to char type
WRGMatrix(:,:,i)=WRGreader(data); %Function to read the files and save them in a 3D Matrix
end
handles.WRGMatrix=WRGMatrix;
handles.nfiles=nfiles;
guidata(hObject, handles);
elseif ischar(filesnames)==1
warndlg('Select atleast 2 files to compute')
end
-----------------------\\--------------------
Accepted Answer
More Answers (1)
Pedro Pedrosa
on 23 Mar 2017
0 votes
Categories
Find more on Migrate GUIDE Apps 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!