How do you code a toggle button to start/stop function that are plotting on a graph in a GUI?
조회 수: 7 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
Geoff Hayes
2017년 4월 13일
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?).
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!