ERROR USING SET() ? GUI, Handles

조회 수: 6 (최근 30일)
Paulo
Paulo 2011년 8월 27일
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
Jan
Jan 2011년 8월 27일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Paulo Silva
Paulo Silva 2011년 8월 27일
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
  댓글 수: 2
Paulo
Paulo 2011년 8월 28일
Would I just include the "best solution functions" on my code after the while loop? or inside the while loop?
Paulo Silva
Paulo Silva 2011년 8월 28일
inside it

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by