Dynamic Properties and ConstructOnLoad - MATLAB & Simulink (original) (raw)

Main Content

Setting the class ConstructOnLoad attribute to true causes MATLAB® to call the class constructor when loading the class. MATLAB saves and restores dynamic properties when loading an object.

If you create dynamic properties from the class constructor, you can cause a conflict if you also set the class ConstructOnLoad attribute to true. Here is the sequence:

If you use ConstructOnLoad, add dynamic properties from the class constructor, and want the constructor to call addprop at load time, then set the dynamic property Transient attribute to true. This setting prevents the property from being saved. For example:

classdef (ConstructOnLoad) MyClass < dynamicprops function obj = MyClass P = addprop(obj,'DynProp'); P.Transient = true; ... end end

See Also

Topics