Main Content

matlab.metadata.DynamicProperty Class

Namespace: matlab.metadata
Superclasses: matlab.metadata.Property

Describe dynamic property of MATLAB object

Renamed from meta.DynamicProperty in R2024a

Description

The matlab.metadata.DynamicProperty class contains descriptive information about dynamic properties that have been added to an instance of a MATLAB® class. To add a dynamic property to a class instance, the class must be a subclass of the dynamicprops class. The properties of the matlab.metadata.DynamicProperty class correspond to property attributes. Dynamic properties are not defined in classdef blocks, but you can set their attributes by setting the matlab.metadata.DynamicProperty object properties.

Add a dynamic property to an object using the addprop method of the dynamicprops class. The addprop method returns a matlab.metadata.DynamicProperty instance representing the new dynamic property. You can modify the properties of the matlab.metadata.DynamicProperty object to set the attributes of the dynamic property or to add set and get access methods, which, for regular properties, would be defined in the classdef file.

To remove the dynamic property, call the delete handle class method on the matlab.metadata.DynamicProperty object.

See Dynamic Properties — Adding Properties to an Instance for more information.

The matlab.metadata.DynamicProperty class is a handle class.

Class Attributes

Abstract
true
Sealed
true

For information on class attributes, see Class Attributes.

Creation

You cannot instantiate a matlab.metadata.DynamicProperty object directly. The addprop method returns a matlab.metadata.DynamicProperty object when you add a dynamic property to an object. Use findprop to get the matlab.metadata.DynamicProperty object for an object that already has a dynamic property.

Properties

expand all

Name of the dynamic property, returned as a character vector.

This property is not used.

This property is not used.

Value of property attribute GetAccess, returned as one of these values:

public – unrestricted access

protected – access from class or subclasses

private – access by class members only

Value of property attribute SetAccess, returned as one of these:

public – unrestricted access

protected – access from class or subclasses

private – access by class members only

Value of property attribute Dependent, returned as a logical. If false, the property value is stored in the object. If true, the property value is not stored in the object and the set and get methods cannot access the property by indexing into the object using the property name. The value of a dependent property depends on some other value, therefore, dependent properties must define access methods to determine the value. For more information, see Get and Set Methods for Dependent Properties.

Value of property attribute Constant. For dynamic properties, the value is always false. Changing the Constant attribute of a dynamic property is not supported. Dynamic properties cannot be constant.

Value of property attribute Abstract. For dynamic properties, the value is always false. Changing the Abstract attribute of a dynamic property is not supported. Dynamic properties cannot be abstract.

Value of property attribute Transient, specified as a logical value. If true, the property value is not saved when the object is saved to a file. See Default Save and Load Process for Objects for more about saving objects.

Value of property attribute Hidden, returned as a logical value. This attribute determines if the property is shown in property lists, such as the Property Inspector or the output of the properties function.

Value of property attribute GetObservable, specified as a logical value. If true, then listeners can be created for property get events. MATLAB calls the listeners whenever property values are queried. See Property-Set and Query Events.

Value of property attribute SetObservable, specified as a logical value. If true, listeners can be created for property set events. MATLAB calls the listeners whenever property values are modified. See Property-Set and Query Events.

Value of property attribute AbortSet, specified as a logical value. If true, then MATLAB does not set the property value if the new value is the same as the current value. Aborted set operations do not trigger the property PreSet and PostSet events.

Value of property attribute NonCopyable, specified as a logical value. NonCopyable determines if the dynamic property can be copied when the object is copied. By default, dynamic properties are not copied. For more information, see Exclude Properties from Copy.

Value of property attribute PartialMatchPriority, specified as a positive integer. This property is used with subclasses of matlab.mixin.SetGet to define the relative priority of partial property name matches used in set and get methods. The default value is 1. Greater values assign lower priorities.

For more information, see Set Priority for Matching Partial Property Names.

Property get method, returned as a function handle. The function handle refers to the get method associated with this property. The value is empty if there is no get method specified. See Get Method Syntax.

Property set method, returned as a function handle. The function handle refers to the set method associated with this property. The value is empty if there is no set method specified. See Property Get and Set Methods.

Indicates if the property has a default value. For dynamic properties, the value is always false. Dynamic properties cannot define default values.

Validation defined for the property. For dynamic properties, the value is always an empty matlab.metadata.Validation array. Dynamic properties do not support validation.

Class that defines the property. For dynamic properties, the value is always an empty matlab.metadata.Class array. Dynamic properties are not defined by classes.

Events

Event NameTriggerEvent DataEvent Attributes
PreGetEvent occurs just before the property value is queried.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

PostGetEvent occurs just after the property value has been queried.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

PreSetEvent occurs just before the property value is changed.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

PostSetEvent occurs just after the property value has been changed.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

Examples

Return matlab.metadata.DynamicProperty Object

Create an instance of MySimpleClass. Use the addprop method of the dynamicprops class to add a dynamic property to an object and return a matlab.metadata.DynamicProperty object.

classdef MySimpleClass < dynamicprops
end
obj = MySimpleClass;
mdp = addprop(obj,"InstanceProp")
mdp = 

  DynamicProperty with properties:

                    Name: 'InstanceProp'
             Description: ''
     DetailedDescription: ''
               GetAccess: 'public'
               SetAccess: 'public'
               Dependent: 0
                Constant: 0
                Abstract: 0
               Transient: 0
                  Hidden: 0
           GetObservable: 0
           SetObservable: 0
                AbortSet: 0
             NonCopyable: 1
    PartialMatchPriority: 1
               GetMethod: []
               SetMethod: []
              HasDefault: 0
              Validation: [0×0 matlab.metadata.Validation]
           DefiningClass: [0×0 matlab.metadata.Class]

Make the property hidden by setting the Hidden property of the matlab.metadata.DynamicProperty object.

mdp.Hidden = true;

Version History

Introduced in R2008a

expand all