Some class updates cause situations in which MATLAB cannot update existing objects to
conform to a modified class definition. These cases result in errors until you delete the
objects:
- Adding an enumeration block to a non-enumeration class
- Redefining a class to be abstract
- Removing a class from a heterogeneous hierarchy that results in there being no
default object to replace existing objects in a heterogeneous array - Updating a class to restrict array formation behavior, such as overloading array
indexing and concatenation. - Inheriting a subsref, subsasgn, cat, vertcat, or horzcat method
- Redefining a handle class to be a value class.
Potential Consequences of Class Updates
- Following an update, existing objects can be incompatible with the new class
definition. For example, a newly added property can require execution of the
constructor to be valid. - Removing or renaming properties can lose the data held in the property. For example,
if a property holds the only reference to another object and you remove that property
from the class, the MATLAB deletes the object because there are no longer any
references to it. - Removing a class from a heterogeneous class hierarchy can result in invalid
heterogeneous array elements. In this case, the default object for the heterogeneous
hierarchy replaces these array elements.
Updates to Class Attributes
Changing class attributes can change existing object behavior or make the objects invalid.
MATLAB returns an error when you access the invalid objects.
Change Effect
Make Abstract = true Accessing existing objects returns an error.
Change AllowedSubclasses Newly created objects can inherit from different
superclasses than existing objects.
5 Class Definition—Syntax Reference