Dominant Argument in Overloaded Graphics Functions
In this section...
“Graphics Object Precedence” on page 9-49
“Dominant Argument” on page 9-49
“Defining Class Precedence” on page 9-49
“Calls to Inferior-Class Methods” on page 9-51
Graphics Object Precedence
MATLAB graphics objects have the same precedence as objects of classes defined using
the classdef syntax. If you want to implement a method that accepts a graphics object
as its first argument (for example, an axes handle), but dispatches to the method of your
class, define the MATLAB graphics class as inferior to your class.
Dominant Argument
When evaluating expression involving objects of more than one class, MATLAB uses the
dominant argument to determine which method or function to call.
Here is how MATLAB dispatches in response to a function call:
- Determine the dominant argument based on the class of arguments.
- If there is a dominant argument, call the method of the dominant class.
- If arguments are of equal precedence, use the leftmost argument as the dominant
argument. - If the class of the dominant argument does not define a method with the name of the
called function, call the first function on the path with that name.
Defining Class Precedence
Specify the relative precedence of MATLAB classes using the InferiorClasses class
attribute. Here is the basic syntax:
classdef (InferiorClasses = {?class1,?class2}) ClassName
Dominant Argument in Overloaded Graphics Functions