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.

 Respuesta aceptada

Image Analyst
Image Analyst el 20 de Dic. de 2013
Editada: Image Analyst el 20 de Dic. de 2013

0 votos

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.

Más respuestas (0)

Categorías

Más información sobre Desktop en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 20 de Dic. de 2013

Comentada:

el 20 de Dic. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by