subsindex
- :
idx =subsindex(obj)¶ Turn an object into subscripts.
When an object of a user-defined class appears inside the parentheses of an indexing expression, the class’s
subsindexmethod is called to translate the object into a plain index vector. The method must return real integers of class"double"counted from zero, not from one.For a class whose constructor is
function obj = picker (sel) obj = class (struct ("sel", sel), "picker"); endfunctiona method
function idx = subsindex (obj) idx = double (obj.sel) - 1; endfunction
lets the object be used directly as a subscript:
p = picker ([2, 4]); v = 10:10:60; v(p) ⇒ 20 40