By Closing GUI, clear all global variables.

I am having a problem, when I close my GUI, I want all global variables to be cleared so when next time I run program of GUI, everything starts from new inputs.

답변 (1개)

Kojiro Saito
Kojiro Saito 2020년 5월 18일

0 개 추천

Assuming you're creating App Designer app (UI Figure-based app), you can set CloseRequestFcn in uifigure. If you're using App Designer, from Comonent Browser, you can add CloseRequestFcn callback.
In this callback definition, add the following to clearall global variables.
clear global
For detail, please read the following document.
Documet: CloseRequestFcn (in UI Figure)

댓글 수: 3

Ahsan Malik
Ahsan Malik 2020년 5월 18일
I am using GUIDE. Kindly tell me the procedure in GUIDE for how to clear everything when GUI closes using the red cross button on top-right.
Adam Danz
Adam Danz 2020년 5월 18일
For GUIDE GUIs, first add a close request function by opening your GUI in GUIDE, right-click the GUI background figure, and view callbacks. Select "CloseRequestFcn". That will add the close request function to your GUI code.
Then add clear global to the function.
Note that it's better to avoid using global variables altogether. They can cause many problems and you do not need to use them.
Ahsan Malik
Ahsan Malik 2020년 5월 18일
Thank you so much brother, I check this out.

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

카테고리

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

태그

질문:

2020년 5월 18일

댓글:

2020년 5월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by