MATLAB Creating Graphical User Interfaces

(ff) #1

Create Helper Functions in App Designer


Helper functions are MATLAB functions that you define in your app so that you can call
them at different places in your code. For example, you might want to update a plot after
the user changes a number in an edit field or selects an item in a drop-down list. Creating
a helper function allows you to single-source the common commands and avoid having to
maintain redundant code.

There are two types of helper functions: private functions, which you can call only inside
your app, and public functions, which you can call either inside or outside your app.
Private functions are commonly used in single-window apps, while public functions are
commonly used in multiwindow apps.

Create a Helper Function


Code View provides a few different ways to create a helper function:


  • Expand the drop-down menu from the bottom half of the Function button in the
    Editor tab. Select Private Function or Public Function.

  • Select the Functions tab in the Code Browser, expand the drop-down list on the
    button, and select Private Function or Public Function.


Create Helper Functions in App Designer
Free download pdf