MATLAB Object-Oriented Programming

(Joyce) #1
Values of the Indexing Structure ..................... 17-23
Typical Patterns for Indexing Methods ................ 17-23

Indexed Reference .................................. 17-28
How Indexed Reference Works...................... 17-28
Compound Indexed References...................... 17-29

Indexed Assignment................................ 17-31
How Indexed Assignment Works..................... 17-31
Indexed Assignment to Objects...................... 17-33
Compound Indexed Assignments.................... 17-33

end as Object Index................................. 17-35
Define end Indexing for an Object.................... 17-35
The end Method................................. 17-36

Objects in Index Expressions ......................... 17-37
Objects Indexes................................. 17-37
Ways to Implement Objects as Indices................ 17-37
subsindex Implementation......................... 17-37

Class with Modified Indexing......................... 17-39
How to Modify Class Indexing ...................... 17-39
Class Description................................ 17-39
Specialize Subscripted Reference — subsref............ 17-40
Specialize Subscripted Assignment — subsasgn......... 17-42
Implement Addition for Object Data — double and plus... 17-43
MyDataClass.m................................. 17-44

Operator Overloading............................... 17-47
Why Overload Operators .......................... 17-47
How to Define Operators.......................... 17-47
Sample Implementation — Addable Objects............ 17-48
MATLAB Operators and Associated Functions........... 17-50

Customizing Object Display


18


Custom Display Interface............................. 18-2
Default Object Display............................. 18-2

xxviii Contents

Free download pdf