MATLAB Creating Graphical User Interfaces

(ff) #1

  • Click on the Properties tab in the Code Browser, expand the drop-down list on the
    button, and select Private Property or Public Property.


After you select an option to create a property, App Designer adds a property definition
and a comment to a properties block.

properties (Access = public)
Property % Description
end

The properties block is editable, so you can change the name of the property and edit
the comment to describe the property. For example, this property stores a value for
average cost:

properties (Access = public)
X % Average cost
end

If your code needs to access a property value when the app starts, you can initialize its
value in the properties block or in the StartupFcn callback.

properties (Access = public)
X = 5; % Average cost
end

Elsewhere in your code, use dot notation to get or set the value of a property:

y = app.X % Get the value of X
app.X = 5; % Set the value of X

17 App Programming

Free download pdf