How to terminate a script using a pushbutton i GUI?

조회 수: 8 (최근 30일)
JoE
JoE 2014년 4월 28일
댓글: JoE 2014년 4월 30일
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

답변 (1개)

Kyle C
Kyle C 2014년 4월 28일
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
JoE
JoE 2014년 4월 30일
Thanks for the response. I tried this but it did not work. What did you mean the function "functiontostop" must be interruptable?

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

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by