Main Content

addprop

Class: dynamicprops

Add dynamic property

Description

P = addprop(A,PropertyName) adds a property named PropName to each object in array A. The output argument P is an array of matlab.metadata.DynamicProperty objects that is the same size as A.

Dynamic properties exist only on the specific instance for which they are defined. Dynamic properties do not become part of the class definition.

You can add dynamic properties only to objects derived from the dynamicprops class. Access the data in dynamic properties using the instance variable and the property name (obj.PropertyName).

example

Input Arguments

expand all

Input array, specified as an object array of a class that is derived from dynamicprops.

Name of dynamic property, specified as a char vector.

Example: 'DynoProp'

Data Types: char | string

Output Arguments

expand all

Output array returned as an array of matlab.metadata.DynamicProperty objects. Use matlab.metadata.DynamicProperty objects to define access methods for dynamic properties, to set property attributes, and to remove dynamic properties.

Attributes

AccessPublic

To learn about attributes of methods, see Method Attributes.

Examples

Add Dynamic Property

Add a dynamic property to an object of the Dyno class.

classdef Dyno < dynamicprops
   properties
      Prop1
   end
end

Create an object

o = Dyno;

Add a property called DynoProp

p = addprop(o,'DynoProp');

Set the AbortSet attribute of the dynamic property

p.AbortSet = 1;

Remove the dynamic property

delete(p)

Version History

Introduced in R2008a