Hey, so my problem is my function stops when i press the stop button on the gui, but it doesn't stay stopped. It will continue on to the next value in the for loop. The following code is how i'm trying to stop the function:
for i = 1:length(DRAW)
drawnow()
stop_state = get(handles.STOP,'Value');
if stop_state
kill = 1
else
kill = 0
end
[out_Params, Inter_params, out_J, time, FLAG] = RECIRC_FO_design_GUI(sol_props, ...
INLET_PARAMS, FEED_PARAMS, DRAW_PARAMS, SYSTEM_PARAMS, MEM_PARAMS, MW_salt, DRAW(i), kill);
if kill
kill = 1;
break;
end
end
I put a condition in the function itself that would stop it, but when i check the value after hitting the stop button, the value is still 0 instead of 1. I've looked at the previously answered question regarding this topic, and they work just the function won't stay stopped. the stop button is just a push button that when pressed sets it's handle value to 1.

 채택된 답변

Image Analyst
Image Analyst 2013년 12월 20일
편집: Image Analyst 2013년 12월 20일

0 개 추천

Yeah, doing it by a button doesn't work. The problem is that your copy of handles is not getting updated. What I do is to have a checkbox that says "Finish now". I make it visible when the loop starts, and when my loop gets to the bottom, it checks the value of the checkbox, and if it's true, it sets the checkbox to false, sets it invisible again, and breaks out of the loop.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Desktop에 대해 자세히 알아보기

태그

질문:

2013년 12월 20일

댓글:

2013년 12월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by