How to get a push button to end a loop in a GUI?
15 views (last 30 days)
I have created a GUI using GUIDE. The purpose is to plot an animation of a very simple projectile motion equation. I have edit text fields to enter the initial angle and velocity, drop downs to select the units, and two push buttons, one to plot and one to stop. Everything works well except for the stop button. I cannot seem to get it to interrupt the loop. I unchecked the interruptible box in the editor for the plot button. I don't have a very good grasp on the callback functions or hObjects or handles, and I would like a simple resolution. Can someone give me an idea of what I am doing wrong in the code below?
This is homework, but adding stop functionality is not part of the assignment, this is just something I would like to do. We are only required to create a simple GUI; the animation is not even necessary.
Ingrid on 6 May 2015
Edited: Ingrid on 6 May 2015
you need to set a flag when you press the pusbutton to stop so in your pushbutton4 callback you should put this instead of the code you have there now:
% Update handles structure
then in the for loop you should put this
to be able to rerun your animation you should also put this after your for-loop
You also need to set the Interruptibility of pushbutton1 to on (change this in guide)
it also seems that you are missing a call to
right before the end of your for-loop because otherwise you do not see your animation move
and finally may I ask why you do not use a semi-colon to surpriss output being shown in the command window?