Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Object Indexing

Customize subscripted reference and assignment for your class.

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

numArgumentsFromSubscriptNumber of arguments for customized indexing methods
subsrefRedefine subscripted reference for objects
subsasgnRedefine subscripted assignment
subsindexConvert object to array index
substructCreate structure argument for subsasgn or subsref
builtinExecute built-in function from overloaded method

Topics

Customize Subscripted Indexing

Object Array Indexing

MATLAB classes support object array indexing by default.

Indexed Reference

Learn how to modify subscripted reference.

Indexed Assignment

Learn how to modify 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 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

end as Object Index

Learn how to implement the use of end for object indexing.

Objects in Index Expressions

You can design objects that can be used as indices in indexing expressions.

Class with Modified Indexing

This sample class implementation modifies object indexing.

Was this topic helpful?