Error evaluationg 'OpenFcn' because of a waitfor command

조회 수: 3 (최근 30일)
Ali
Ali 2022년 10월 17일
댓글: Ali 2022년 10월 18일
Hi,
I have a gui, that when close with a cancle or the X at the top right corner of the gui will give me this error :
The reason why i get this error is because in my program i have a waitfor command that waits for the user to click on pushbutton to allow the rest of the programm to run (that waitfor command is pretty essential for the programm). This error happens if the gui is closed before the pushbutton associated to the waitfor command is pressed.
Is there a way to not have this error message without removing the waitfor ?

채택된 답변

Rik
Rik 2022년 10월 17일
You need to use return instead of guidata(hObject,handles) if the figure no longer exists.
If you want more specific advice, you will have to show more specific code.
  댓글 수: 6
Rik
Rik 2022년 10월 18일
You should put a call to drawnow in your loop. That way, you tell Matlab to execute any queued graphics changes/interactions, including button callbacks.
Calling pause (with some value as an argument) will have a similar effect. The reason it works in the debugger is that every time the code execution stops, callbacks are processed.
Ali
Ali 2022년 10월 18일
ok thank you for the answer

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2012a

Community Treasure Hunt

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

Start Hunting!

Translated by