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.
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
Events
Event Name | Trigger | Event Data | Event Attributes |
---|---|---|---|
PreGet | Event occurs just before the property value is queried. | event.PropertyEvent |
|
PostGet | Event occurs just after the property value has been queried. | event.PropertyEvent |
|
PreSet | Event occurs just before the property value is changed. | event.PropertyEvent |
|
PostSet | Event occurs just after the property value has been changed. | event.PropertyEvent |
|
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;