MATLAB CTL-C GUI Cleanup

7 Ansichten (letzte 30 Tage)
Sarah Crimi
Sarah Crimi am 25 Jun. 2018
Kommentiert: Sarah Crimi am 3 Jul. 2018
Hello, I have created a GUI to collect some data. This GUI uses some equipment that has to be connected/disconnected to MATLAB with commands. I want to make it so that when you push CTL-C to stop running something any of the functions, the equipment is disconnected properly. Is that possible without using "oncleanup" with putting it in every function used in the GUI?

Antworten (1)

Walter Roberson
Walter Roberson am 25 Jun. 2018
When you launch the GUI, have a function create an oncleanup, and then have the function uiwait() or waitfor() the gui figure. The control-C will trigger exiting the uiwait() or waitfor(), causing the function to exit, triggering the oncleanup .
... at least in theory.
  5 Kommentare
Walter Roberson
Walter Roberson am 28 Jun. 2018
Hmmm, https://www.mathworks.com/matlabcentral/answers/156803-detection-of-ctrl-c-in-m-file suggests using onCleanup, which agrees with my memory, and when I test the code there it works. But I agree that the onCleanup does not seem to get invoked for ^C for waitfor() or uiwait() so I do not know what the solution is.
Sarah Crimi
Sarah Crimi am 3 Jul. 2018
thanks for your help :)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Error Handling finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by