How can I get the value of toggle button (uicontrol)
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mehdi
el 11 de Mzo. de 2015
Comentada: Mehdi
el 11 de Mzo. de 2015
Hi fellow MATLAB users,
I have created a toggle button in a figure programmatically using uicontrol:
tb = uicontrol(gtfig, 'Style', 'togglebutton', 'String', 'Start/Stop', 'tag', 'togglebutton1', 'Position', [30 20 100 30])
How can I get its value after it's pressed? Apparently, the code:
button_state = get(hObject,'Value');
that is used in GUIDE can't be used here. Thank you for your help.
0 comentarios
Respuesta aceptada
Yoav Livneh
el 11 de Mzo. de 2015
You need to set a callback function for the button if you want something to happen when it is pressed. For example:
% set callback fnuction
set(tb,'Callback',@fun1);
% example for callback function
function fun1(hObject,eventData)
button_state = get(hObject,'Value');
end
Más respuestas (1)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!