The paper develops a set of member functions in MATLAB that implement the tailoring in a way that allows objects to mimic structures. It takes advantage of a pair of standard, but relatively unknown, functions, subsref.m and subsasgn.m. The built-in versions operate on structures. Tailored versions, as long as MATLAB can find them, operate on objects. As tailored member functions, subsref.m and subsasgn.m are so critical to object-oriented programming that they share a place beside the constructor in the group of eight.
Chapter Contents:
- 4.1 A Special Accessor and a Special Mutator
- 4.1.1 A Short Side Trip to Examine Overloading
- 4.1.1.1 Superiorto and Inferiorto
- 4.1.1.2 The Built-in Function
- 4.1.2 Overloading the Operators subsref and subsasgn
- 4.1.2.1 Dot-Reference Indexing
- 4.1.2.2 subsref Dot-Reference, Attempt 1
- 4.1.2.3 A New Interface Definition
- 4.1.2.4 subsref Dot-Reference, Attempt 2: Separating Public and Private Variables
- 4.1.2.5 subsref Dot-Reference, Attempt 3: Beyond One-to-One, Public-to-Private
- 4.1.2.6 subsref Dot-Reference, Attempt 4: Multiple Indexing Levels
- 4.1.2.7 subsref Dot-Reference, Attempt 5: Operator Conversion Anomaly
- 4.1.2.8 subsasgn Dot-Reference
- 4.1.2.9 Array-Reference Indexing
- 4.1.2.10 subsref Array-Reference
- 4.1.2.11 subsasgn Array-Reference
- 4.1.2.12 Cell-Reference Indexing
- 4.1.3 Initial Solution for subsref.m
- 4.1.4 Initial Solution for subsasgn.m
- 4.1.5 Operator Overload, mtimes
- 4.2 The Test Drive
- 4.2.1 subsasgn Test Drive
- 4.2.2 subsref Test Drive
- 4.3 Summary
- 4.4 Independent Investigations
Inspec keywords:
object-oriented programming
Other keywords:
MATLAB member function;
subsasgn.m function;
subsref.m function;
MATLAB member structure;
object-oriented programming
Subjects:
Object-oriented programming