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.
MATLAB classes support object array indexing by default.
Learn about subscripted reference.
Learn about subscripted assignment.
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 returned 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.
Learn how to implement the use of end
for object indexing.
You can design objects that can be used as indices in indexing expressions.
This sample class implementation modifies object indexing.