Hi all,
I have a script that creates a waiting UI bar for the time of the for loop:
wb = waitbar(0,'Name','My waitBar');
for t = 0:t_end
do_stuff(t, other_stuff);
waitbar(t / span(end), wb);
end
delete(wb);
However, when I try some things in do_stuff, I sometimes (often) have errors. So the script stops, but the UI windows remain and is impossible to close.
I thought a try/catch thing, but is there an easier way to get rig of those ghost windows?

 채택된 답변

Adam Danz
Adam Danz 2019년 10월 2일
편집: Adam Danz 2019년 10월 2일

1 개 추천

I think it's a bad idea to automatically close the figure whenever there's an error since the figure may contain information that helps to diagnose the problem.
To close the figure manually, select the figure and then delete or force-close.
figure('CloseRequestFcn', [])
delete(gcf)
% or
close(gcf,'force')
[Update]
To delete a stubborn ui figure, select it and use closereq.
uifigure('CloseRequestFcn',[])
closereq

댓글 수: 6

Thomas Barbier
Thomas Barbier 2019년 10월 2일
편집: Thomas Barbier 2019년 10월 2일
Thanks for your answer.
Well it's not a figure but a UI window:
Nothing can make it close right now. Neither the red cross or delete('wb')...
Adam Danz
Adam Danz 2019년 10월 2일
I updated my answer. Use closereq() to show that UI figure who's boss.
Adam Danz
Adam Danz 2019년 10월 2일
I'm a bit puzzled. Waitbar() produces a regular figure panel, not a UI figure. How is your waitbar a uifigure?
Thomas Barbier
Thomas Barbier 2019년 10월 2일
Sorry, surely the wrong name. For me, UI = everything that allows to interact with the user.
Thomas Barbier
Thomas Barbier 2019년 10월 2일
closereq works like a charm. Thank sa lot :)
Adam Danz
Adam Danz 2019년 10월 2일
편집: Adam Danz 2019년 10월 2일
Glad I could help.
There's nothing wrong with your interpretation of "UI Figure" since that's exactly what it implies - a user interface figure. However, matlab's function to create app designer figures is uifigure() which produces a different type of figure with different properties than figure(). Both can be used to create a user interface.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2019년 10월 2일

편집:

2019년 10월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by