Defining Your Own Classes
All MATLAB data types are implemented as object-oriented classes. You can add data types of your
own to your MATLAB environment by creating additional classes. These user-defined classes define
the structure of your new data type, and the functions, or methods, that you write for each class
define the behavior for that data type.
These methods can also define the way various MATLAB operators, including arithmetic operations,
subscript referencing, and concatenation, apply to the new data types. For example, a class called
polynomial might redefine the addition operator (+) so that it correctly performs the operation of
addition on polynomials.
With MATLAB classes you can
• Create methods that overload existing MATLAB functionality
• Restrict the operations that are allowed on an object of a class
• Enforce common behavior among related classes by inheriting from the same parent class
• Significantly increase the reuse of your code
For more information, see “Role of Classes in MATLAB”.
17
All MATLAB data types are implemented as object-oriented classes. You can add data types of your
own to your MATLAB environment by creating additional classes. These user-defined classes define
the structure of your new data type, and the functions, or methods, that you write for each class
define the behavior for that data type.
These methods can also define the way various MATLAB operators, including arithmetic operations,
subscript referencing, and concatenation, apply to the new data types. For example, a class called
polynomial might redefine the addition operator (+) so that it correctly performs the operation of
addition on polynomials.
With MATLAB classes you can
• Create methods that overload existing MATLAB functionality
• Restrict the operations that are allowed on an object of a class
• Enforce common behavior among related classes by inheriting from the same parent class
• Significantly increase the reuse of your code
For more information, see “Role of Classes in MATLAB”.
17
