MATLAB Creating Graphical User Interfaces

(ff) #1

Startup Tasks and Input Arguments in App Designer


App Designer allows you to create a special function that executes when the app starts
up, but before the user interacts with the UI. This function is called the StartupFcn
callback, and it is useful for setting default values, initializing variables, or executing
commands that affect initial state of the app. For example, you might use the
StartupFcn callback to display a default plot or a show a list of default values in a table.

Create a StartupFcn Callback


To create a StartupFcn callback, right-click the UIFigure component in the
Component Browser, and select Callbacks > Add StartupFcn callback.

App designer creates the function and places the cursor in the body of the function. Add
commands to this function as you would do for any callback function. Then save and run
your app.

17 App Programming

Free download pdf