Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Properties

Property declaration, attributes, and access methods.

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.

Functions

properties Class property names
isprop Determine if property of object
mustBeFinite Validate that value is finite or issue error
mustBeGreaterThan Validate that value is greater than another value or issue error
mustBeGreaterThanOrEqual Validate that value is greater than or equal to another value or issue error
mustBeInteger Validate that value is integer or issue error
mustBeLessThan Validate that value is less than another value or issue error
mustBeLessThanOrEqual Validate that value is less than or equal to another value or issue error
mustBeMember Validate that value is member of specified set
mustBeNegative Validate that value is negative or issue error
mustBeNonempty Validate that value is nonempty or issue error
mustBeNonNan Validate that value is nonNaN
mustBeNonnegative Validate that value is nonnegative or issue error
mustBeNonpositive Validate that value is nonpositive or issue error
mustBeNonsparse Validate that value is nonsparse or issue error
mustBeNonzero Validate that value is nonzero or issue error
mustBeNumeric Validate that value is numeric or issue error
mustBeNumericOrLogical Validate that value is numeric or logical or issue error
mustBePositive Validate that value is positive or issue error
mustBeReal Validate that value is real or issue error

Classes

dynamicprops Superclass for classes that support dynamic properties
meta.DynamicProperty Describe dynamic property of MATLAB object
event.DynamicPropertyEvent Event data for dynamic property events
meta.property Describe property of MATLAB class
matlab.lang.OnOffSwitchState Represent on and off states with logical values

Topics

Define Properties and Set Attributes

Ways to Use Properties

There are different kinds of properties and each serves a different purpose.

Property Syntax

When you define properties, you also specify property attributes that control certain aspects of the property's behavior.

Property Attributes

Attributes control the behavior of properties.

Mutable and Immutable Properties

You can control what code can set property values.

Property Definition

Classes can assign default values to properties and you can change these values during object construction or direct access to the properties.

Properties with Constant Values

Use a class with Constant properties to define constant values

Properties Containing Objects

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.

Property Validation

Validate Property Values

You can restrict property values to a size and class, and apply functions to validate assigned values.

Property Class and Size Validation

MATLAB® applies any class and size validation defined for a property before calling validation functions.

Property Validation Functions

Property validation functions enable you to check the values being assigned to properties.

Property Access Methods

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

Property set methods must follow specific syntax and execution rules.

Property Get Methods

Property get methods must follow specific syntax and execution rules.

Access Methods for Dependent Properties

Dependent properties need access methods because these properties do not store values. Property access methods manage interactions with the dependent properties.

Dynamic Properties

Dynamic Properties — Adding Properties to an Instance

You can add instance data to an object derived from the dynamicprops class.

Access Methods for Dynamic Properties

You can implement what are effectively access methods for dynamic properties.

Dynamic Property Events

You can define listeners for PropertyAdded and PropertyRemoved events on dynamic properties.

Dynamic Properties and ConstructOnLoad

Use the ConstructOnLoad attribute to save and load dynamic properties.

Was this topic helpful?