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});

 Accepted Answer

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 Comments

but I want to directly put behind @(src,event) for very simple functions without defining functions.
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)');

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Tags

Asked:

on 10 Mar 2024

Commented:

on 10 Mar 2024

Community Treasure Hunt

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

Start Hunting!