How do you code a toggle button to start/stop function that are plotting on a graph in a GUI?

8 Ansichten (letzte 30 Tage)
I am creating a GUI to teach simple projectile motion. I have two slider inputs for initial velocity and launch angle. With those two inputs, I have created a height vs. time graph within the GUI. I am interested in starting/stopping the function from plotting using a toggle button. I want the button to start out on stop, and for the user to push start to start the animated graph.

Antworten (1)

Geoff Hayes
Geoff Hayes am 13 Apr. 2017
Kam - if you want have a "process" running in the background (that you start by pressing the toggle button) then you may want to use a timer that will periodically perform an action. You could start it when you press the button, and stop the timer when you press the toggle again.
See https://www.mathworks.com/matlabcentral/answers/331892-matlab-timer-code-stop-button-to-clear-graph-and-bar-graph-whilst-having-real-time-data some of which can be used for your GUI. I think it all depends upon what your function is doing - presumably you pass or it reads the velocity and height and then draws the motion (in real-time?).

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by