How to use the same button to begin and end a callback
Show older comments
Hello,
I have the following code:
Traj_Button = uicontrol('Style','pushbutton', 'String','Start', 'Units', 'normalized', 'Position',[0.8,0.7,0.15,0.05], 'Callback',{@Traj_Button_Callback});
function Traj_Button_Callback(source,eventdata)
if strcmp(source.String, 'Start')
source.String = 'Start';
while % Button not pushed
% code
end
else
source.String = 'End';
end
I would like to use the same pushbutton to start my callback function, and wait to en end it that user pushes the button again.
2 Comments
Stephen23
on 15 Nov 2017
Have a look at the 'Demo' button of my FEX submission CubeHelix, it uses a toggle button to control a loop. You could do something similar with a push button.
Sébastien Marlio-Marette
on 15 Nov 2017
Answers (0)
Categories
Find more on Interactive Control and Callbacks 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!