How to terminate a script using a pushbutton i GUI?

6 vues (au cours des 30 derniers jours)
JoE
JoE le 28 Avr 2014
Commenté : JoE le 30 Avr 2014
Hi all,
I have a GUI with a few buttons that makes some analysis for me. The duration of this analysis can be in range of few seconds to few minutes.
How can I terminate this analysis (manually finish the script behind this analysis) using one of those buttons (e.g. with the caption 'STOP')?
Is there a way how to do this in GUI (command, keyword or anything else)?
Thank you very much for your response.
JoE

Réponses (1)

Kyle C
Kyle C le 28 Avr 2014
I'm guessing that if the scripts are taking that long you have some loops in there. One way to stop the scripts is to have the stop button set appdata that signals to the scripts that they should stop running. The loops in the scripts should check to see if this signal is telling it to stop or not before each iteration.
sample:
stopbutton callback
setappdata(0,'stopreq',1)
end
functiontostop callback
if ~getappdata(0,'stopreq')
code here
else
setappdata(0,'stopreq',0)
break
end
for this to work the functiontostop must be interruptable.
  1 commentaire
JoE
JoE le 30 Avr 2014
Thanks for the response. I tried this but it did not work. What did you mean the function "functiontostop" must be interruptable?

Connectez-vous pour commenter.

Catégories

En savoir plus sur App Building dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by