multiple actions following @(src,event) in uicontrol

How to add another action or function to the following
Button=uicontrol('Style','pushbutton', 'String','pause','Position',[1800 60 100 100], 'Callback',@(src,event)continue);
so that it becomes sth like
Button=uicontrol('Style','pushbutton', 'String','pause','Position',[1800 60 100 100], 'Callback',@(src,event){continue,close});

 Réponse acceptée

Voss
Voss le 10 Mar 2024
Define a function that has whatever code in it you want.
Then make that function the button's callback:
Button=uicontrol('Style','pushbutton', 'String','pause','Position',[1800 60 100 100], 'Callback',@(src,event)your_function);

4 commentaires

but I want to directly put behind @(src,event) for very simple functions without defining functions.
Voss
Voss le 10 Mar 2024
Modifié(e) : Voss le 10 Mar 2024
The @ symbol makes an anonymous function, so it would be a function call.
Alternatively, you can define the callback as a character vector that executes a sequence of commands in the base workspace:
Button=uicontrol('Style','pushbutton', 'String','pause','Position',[1800 60 100 100], 'Callback','x=5; disp(x)');
perfect, thanks
Voss
Voss le 10 Mar 2024
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by