Object Indexing
Customize indexed reference and assignment behavior for object arrays. Although user-defined classes possess the same indexing behavior as built-in MATLAB®classes, you can modify this behavior when your class has special requirements.
Functions
numArgumentsFromSubscript |
Number of arguments for customized indexing methods |
subsref |
Subscripted reference |
subsasgn |
Redefine subscripted assignment |
subsindex |
Convert object to array index |
substruct |
Create structure argument for subsasgn or subsref |
builtin |
Execute built-in function from overloaded method |
Topics
How Indexing Works
MATLAB classes support object array indexing by default.
Learn about subscripted reference.
Learn about subscripted assignment.
Customize Indexing
Code Patterns for subsref and subsasgn Methods
There are code patterns useful for modifying object indexing.
Number of Arguments for subsref and subsasgn
Classes that modify object array indexing must handle the correct number of arguments retrurned from or passed to indexing methods.
Modify nargout and nargin for Indexing Methods
Modify the number of arguments passed to or returned from indexing methods.
Special Indices
Learn how to implement the use ofend
for object indexing.
You can design objects that can be used as indices in indexing expressions.
This sample class implementation modifies object indexing.