There are functions that MATLAB® calls implicitly when you
perform certain actions with objects. For example, a statement like
indexed reference and vertical concatenation.
You can change how user-defined objects behave by defining methods that control specific behaviors. To change a behavior, implement the appropriate method with the name and signature of the MATLAB function.
The following table lists the methods to implement for your class and describes the behaviors that they control.
Class Method to Implement
Customize behavior when concatenation objects
Creating Empty Arrays
|Create empty arrays of the specified class. See Empty Arrays|
Called when you enter
Called when statements are not terminated
Converting Objects to Other Classes
Convert an object to a MATLAB built-in class
Enables you to create nonstandard indexed reference and indexed assignment
Determine the number of elements in an array
Determine the dimensions of an array
Support using an object in indexing expressions
Saving and Loading Objects
Customize behavior when loading and saving objects
Overloading and overriding are terms that describe techniques for customizing class behavior. Here is how we use these terms in MATLAB.
Overloading means that there is more than one function or method
having the same name within the same scope. MATLAB dispatches
to a particular function or method based on the dominant argument.
For example, the
timeseries class overloads the MATLAB
When you call
plot with a
as an input argument, MATLAB calls
timeseries class method named
To call the nonoverloaded function, use the
Overriding means redefining a method inherited from a superclass. MATLAB dispatches to the most specific version of the method. That is, if the dominant argument is an instance of the subclass, then MATLAB calls the subclass method.
To control class precedence, use the