How can I check from Matlab script if the pushbutton is pressed?
9 views (last 30 days)
Show older comments
% matlab code
myGui; % I am calling now GUI, which has 3 push buttons
now I should check, which of the buttons is pressed?
if the button1 is pressed
do something (matlab code)
elseif button2 is pressed
do something (matlab code)
else
do something (matlab code)
So, how can I check if the Button is pressed from matlab script?
0 Comments
Accepted Answer
Walter Roberson
on 12 Mar 2018
Check the Value property of the uicontrol . It will be 1 when the button is pressed and 0 if the button is not pressed.
However, people often code uicontrol style 'pushbutton'. pushbutton only have value 1 while their Callback are being processed, and immediately return to 0 afterwards. If you need to check outside the Callback to determine whether the button was pressed since you last checked, then you will need to arrange to have the callback set a value in a location that other routines can access. http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
5 Comments
More Answers (0)
See Also
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!
