Convert an object to an index vector.
When obj is a class object defined with a class constructor, then
subsindex
is the overloading method that allows the conversion of
this class object to a valid indexing vector. It is important to note that
subsindex
must return a zero-based real integer vector of the class
"double"
. For example, if the class constructor were
function obj = myclass (a) obj = class (struct ("a", a), "myclass"); endfunction
then the subsindex
function
function idx = subsindex (obj) idx = double (obj.a) - 1.0; endfunction
could be used as follows
a = myclass (1:4); b = 1:10; b(a) ⇒ 1 2 3 4
See also: class, subsref, subsasgn.
Package: octave