Programming and Data Types    

MATLAB Classes and Objects


This chapter describes how to define your own classes in MATLAB. Classes and objects enable you to add new data types and new operations to MATLAB. The class of a variable describes the structure of the variable and indicates the kinds of operations and functions that can apply to the variable. An object is an instance of a particular class. The phrase object-oriented programming describes an approach to writing programs that emphasizes the use of classes and objects.
Classes and Objects: An Overview
Using object-oriented programming in MATLAB
Designing User Classes in MATLAB
The basic set of methods that should be included in a class
Overloading Operators and Functions
Overloading the MATLAB operators and functions to change their behavior
Example -- A Polynomial Class
Example that defines a new class to implement a MATLAB data type for polynomials
Building on Other Classes
Inheritance and aggregation
Example - Assets and Asset Subclasses
An example that uses simple inheritance
Example -- The Portfolio Container
An example that uses aggregation
Saving and Loading Objects
Saving and retrieving user-defined objects to and from MAT-files
Example -- Defining saveobj and loadobj for Portfolio
Defining methods that automatically execute on save and load
Object Precedence
Determining which operator or function to call in a given situation
How MATLAB Determines Which Method to Call
How function arguments and precedence determine which method to call


  Historical Note - Evaluating Function Names Classes and Objects: An Overview