How to stop a for loop execution from GUI?(From Toolbar stop button)
조회 수: 2 (최근 30일)
이전 댓글 표시
I have for loop,,I want to to stop this loop from a toolbar button,, Initially I have set a flag "STOP=0",,,and when I press my stop button in tool bar,,I am calling a function,,where "STOP=1" I have written script,,,,But my script is not considering this"STOP" flag,,,please hep me out>...
댓글 수: 0
채택된 답변
ChristianW
2013년 4월 4일
You can write your flag in the UserData-property of the toolbaricon.
...
set(handles.uitoolbar1,'UserData',0)
for ...
if get(handles.uitoolbar1,'UserData')
break
end
end
...
function uipushtool1_ClickedCallback(hObject, eventdata, handles)
set(handles.uitoolbar1,'UserData',1)
댓글 수: 3
Jan
2013년 4월 5일
The tiny interval for PAUSE is not useful. Use pause to get the shortest possible delay. Usually drawnow is used to allow ui-objects to update.
추가 답변 (1개)
Jan
2013년 4월 4일
Each function has its own workspace, such that a variable set in one function is not visible in the other. A solution is to set a flag e.g. in the UserData of a figure or any other UI-object. This flag can be checked from inside the loop also.
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!