| Programming and Data Types | ![]() |
Indexing an Object with Another Object
When MATLAB encounters an object as an index, it calls the subsindex method defined for the object. For example, suppose you have an object a and you want to use this object to index into another object b.
A subsindex method might do something as simple as convert the object to double format to be used as an index, as shown in this sample code.
function d = subsindex(a) %SUBSINDEX % convert the object a to double format to be used % as an index in an indexing expression d = double(a);
subsindex values are 0-based, not 1-based.
| Defining end Indexing for an Object | Converter Methods | ![]() |