Stop the execution of a function with a push button (GUIDE)
이전 댓글 표시
Hiya!
I have a program, which analyzes a series of images extracting data from them. Now, I have been asked to make a gui in order to be more easily used. I have gotten stuck in the part where I call the program itself from the gui (which, by the moment, is a separate program (m-file)).
The calling of the program is easy, and it works. But, the proccess is long, and sometimes the user wants to stop it, in order to change configuration, for example. I can't do the cancelling part. Here is a scheme of what I've got, and what do I want
[GUIDE]
button -> Calls program.m (and it runs well)
button2 -> Stops program.m (this doesn't work) by changing the 'closing' variable to 1
[program.m]
while i< number of images if 'closing' == 1 -> exit program if not -> analyze the i image
Thank you in advance for your time and your response
채택된 답변
추가 답변 (2개)
Image Analyst
2015년 5월 24일
I have not found a way to do it with a pushbutton. Using it to set a flag, like "finishNow", that you can check in your intensive loop, does not seem to work. The only way I can get something like that to work is to have a checkbox. So you do something like
% Clear flag and make it visible.
set(handles.chkFinishNow, 'Value', 0);
set(handles.chkFinishNow, 'Visible', 'on');
% Now the intensive loop
for k = 1 : 1000000
% Heavy duty code.
% At and of loop, see if user wants to quit
if get(handles.chkFinishNow, 'Value')
% User checked the box
break; % exit the loop
end
end
% Clear flag and make it invisible.
set(handles.chkFinishNow, 'Value', 0);
set(handles.chkFinishNow, 'Visible', 'off');
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
