ERROR USING SET() ? GUI, Handles
2 views (last 30 days)
Show older comments
my code is like this: while microcontroller is connected
if(face detected) set(handles.statusLbl,'String','Capturing iris image . . .'); else set(handles.statusLbl,'String','Idle');
end while
statusLbl is a static text in the GUI
And When I exit the program, an error occurs...
Error using
==> set
Invalid handle
object.
Error in ==> irisrecognition>irisrecognition_OpeningFcn at 124 set(handles.statusLbl,'String','Idle');
Error in ==> gui_mainfcn at 221 feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
Error in ==> irisrecognition at 42 gui_mainfcn(gui_State, varargin{:});
1 Comment
Jan
on 27 Aug 2011
What is your question?
You can use the debugger ("dbstop if error") to find out, why the opening function is called when you stop the program. But there is no chance, that we can guess the cause of the problem.
Answers (1)
Paulo Silva
on 27 Aug 2011
It looks like you have your code inside a while loop, when you exit your GUI the handles are deleted but the loop still tries to set the string of the static text (at least once), the fast solution would be:
try
if(face detected)
set(handles.statusLbl,'String','Capturing iris image . . .');
else
set(handles.statusLbl,'String','Idle')
end
catch
end
The best solution would involve checking if the handles.statusLbl is still a valid handle before setting the text string.
Some functions that might be helpful
any(ismember(who,'handles')) %check if theres one handles variable
strcmp(class(handles),'struct') %check if handles is a structure
isfield(handles,'statusLbl') %check if handles got one field called statusLbl
ishandle(handles.statusLbl) %check if the statusLbl is a valid handle
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!