Is there a possibility to make a Start/Stop Pushbutton in guide?

5 views (last 30 days)
Hey there, I am having a Matlab Gui designed by guide and want to Start/Stop a measurement with one button. Is there a possibility to just stop the measurement by using the same pushbutton and jump out of the function? Or do I have to use two pushbuttons?
  1 Comment
Rik
Rik on 18 Jun 2018
You can have the pushbutton callback function do anything you like, so there is no need to have two buttons. Of course assuming your measurements are interruptible.

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 18 Jun 2018
Edited: Stephen23 on 18 Jun 2018
"Is there a possibility to just stop the measurement by using the same pushbutton and jump out of the function"
Of course you could use a push button to not a logical scalar (or and, or whatever logic you want), or as an alternative you could use a toggle button.
  4 Comments
amship
amship on 19 Jun 2018
Thanks. The last suggestion from you worked well. But after the 'Stop' function ran, the function jumps back to the line where I pressed the Stop button. The behaviour is also described at:
https://de.mathworks.com/help/matlab/creating_guis/callback-sequencing-and-interruption.html
"then MATLAB stops the execution of the running callback and executes the interrupting callback. MATLAB resumes executing the running callback when the interrupting callback completes." Is there a way to not jump back into the 'Start' function?
Stephen23
Stephen23 on 19 Jun 2018
"Is there a way to not jump back into the 'Start' function?"
Not really, because that is the exact concept of interrupts. But you can easily make the Start function check the logical value, or the value of a toggle button. Have a look at the 'Demo' button of my FEX submission cubehelix_view, which lets the while loop iterate indefinitely until the user clicks the button again.

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!