a1 = UseData;
a2 = UseData;
Reference the data using the object variable:
a1.Data.Data1
ans =
MyData1
Assign a new value to the properties in the SharedData object:
a1.Data.Data1 = rand(3);
All new and existing objects of the UseData class share the same SharedData object. a2
now has the rand(3) data that was assigned to a1 in the previous step:
a2.Data.Data1
ans =
0.8147 0.9134 0.2785
0.9058 0.6324 0.5469
0.1270 0.0975 0.9575
To reinitialize the constant property, clear all instances of the UseData class and then
clear the class:
clear a1 a2
clear UseData
Constant Data
To store constant values that do not change, assign the data to a constant property. All
instances of the class share the same value for that property. Control the scope of access
to constant properties by setting the property Access attribute.
The only way to change the value of a constant property is to change the class definition.
Use constant properties like public final static fields in Java®.
See Also
clear | persistent
See Also