Function Reference
— Function File: idx = subsindex (a)

Convert an object to an index vector. When a 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

          function b = myclass (a)
           b = myclass (struct ("a", a), "myclass");
          endfunction

then the subsindex function

          function idx = subsindex (a)
           idx = double (a.a) - 1.0;
          endfunction

can then be used as follows

          a = myclass (1:4);
          b = 1:10;
          b(a)
           1  2  3  4

See also: class subsref subsasgn