Properties contain object data. Classes define the same properties for all object, but each object can have unique data values. Property attributes control what functions or methods can access the property. You can define functions that execute whenever you set or query property values. Properties can trigger events when code accesses their values.
Numeric Value Attribute Validation
|Validate that value is positive|
|Validate that value is nonpositive|
|Validate that value is nonnegative|
|Validate that value is negative|
|Validate that value is finite|
|Validate that value is not NaN|
|Validate that value is nonzero|
|Validate that value is nonsparse|
|Validate that value is real|
|Validate that value is integer|
|Validate that value is not missing|
|Validate that value is greater than another value|
|Validate that value is less than another value|
|Validate that value is greater than or equal to another value|
|Validate that value is less than or equal to another value|
Data Type Validation
|Validate that value comes from one of specified classes|
|Validate that value is numeric|
|Validate that value is numeric or logical|
|Validate that value is floating-point array|
|Validate that value is string array, character vector, or cell array of character vectors|
|Validate that value is single piece of text|
|Validate that value is text with nonzero length|
|Validate that value has specified underlying type|
|Validate that value is nonempty|
|Validate that value is scalar or empty|
|Validate that value is vector|
Member and Range Validation
|Validate that value is member of specified set|
|Validate that value is in the specified range|
Text with Special Meaning Validation
|Superclass for classes that support dynamic properties|
|Describe dynamic property of MATLAB object|
|Event data for dynamic property events|
|Describe property of MATLAB class|
|Describes property validation|
|Fixed dimension in property size specification|
|Unrestricted dimension in property size specification|
|Size information for property validation|
|Represent on and off states with logical values|
Define Properties and Set Attributes
There are different kinds of properties and each serves a different purpose.
When you define properties, you also specify property attributes that control certain aspects of the property’s behavior.
Attributes control the behavior of properties.
Specify a list of classes that can access a property.
You can control what code can set property values.
Classes can assign default values to properties and you can change these values during object construction or direct access to the properties.
Use a class with
Constant properties to define constant values
Properties assigned objects as default values construct that object only once when the class is first loaded. Also, assignment to contained object properties behaves differently depending on whether the object is a handle or value.
You can restrict property values to a size and class, and apply functions to validate assigned values.
Define class and size requirements for a property.
Property validation functions enable you to check the values being assigned to properties.
Programmatically determine the size, class, and validation functions that validate the values assigned to properties.
Property Access Methods
Property access methods execute code when property values are referenced or assigned. Implementing these methods enables you to control what actions occur when values are set or queried.
Property set methods must follow specific syntax and execution rules.
Property get methods must follow specific syntax and execution rules.
Dependent properties need access methods because these properties do not store values. Property access methods manage interactions with the dependent properties.
You can add instance data to an object derived from the
You can implement what are effectively access methods for dynamic properties.
You can define listeners for
PropertyRemoved events on dynamic properties.
ConstructOnLoad attribute to save and load dynamic properties.