There is a problem exiting a loop in a GUI in a clean way. I know there are a lot of threads about this but I could not find a solution.
In my loop an animation is executed using drawnow. When I break the loop using a guidata variable (or userdata as well) the loop is stopped correctly and the animation stops.
When the animation is executed a second time it executes as well but at the end I get an error while setting plot properties.
While debugging I saw, that when the loop was stopped the first time, there is still the transparent debugging arrow pointing at drawnow. I think there is the reason for the error, so how can I avoid this and end the loop definitely.