By Closing GUI, clear all global variables.

15 visualizaciones (últimos 30 días)
Ahsan Malik
Ahsan Malik el 18 de Mayo de 2020
Comentada: Ahsan Malik el 18 de Mayo de 2020
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.

Respuestas (1)

Kojiro Saito
Kojiro Saito el 18 de Mayo de 2020
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 comentarios
Adam Danz
Adam Danz el 18 de Mayo de 2020
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 el 18 de Mayo de 2020
Thank you so much brother, I check this out.

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by