필터 지우기
필터 지우기

How to stop a running script with a push-button and return best solution so far to GUI surface?

조회 수: 1 (최근 30일)
Hi people,
i implemented a GUI with GUIDE that executes an algorithm by pushing a PUSH-Button. The algorithm tends to produce better solutions the longer it runs. The call of the algorithm looks like
[solution_value]=heuristic.m
Now i would like the user to have the possibility to stop the running algorithm and to return the best solution value "solution_value" that was calculated so far! so i dont want to wait until the algorithm is fully finished but stop the execution and return the current value of the return variable... The whole algorithm runs in a while loop, so it would be enough to make the algorithm jump out of the while loop...After that the return variable is assigned in the algorithm and can be given back to the GUI as usual..
How can i manage that?
Thank you very much and best regards, John
  댓글 수: 1
John
John 2016년 1월 2일
When posting the question a simple solution came into my mind:
so i just defined a global variable "stop" that is called into existence as soon as the push button for stopping the function is pressed...
a simple
if stop==1
break
end
manages to break out of the while loop and thats it! Sometimes even just formulating a question really helps:D
best regards

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by