nelson.indexing.IndexingOperation
Describe one element of an indexing expression.
📝Syntax
op = nelson.indexing.IndexingOperation(type, indices)
op = nelson.indexing.IndexingOperation(type, indices, name)
📥Input Arguments
Parameter Description
type a nelson.indexing.IndexingOperationType, or its name as a char/string ('Paren', 'Brace', 'Dot', ...).
indices cell array of the paren/brace subscripts (empty for a dot operation).
name the field name (dot operation only).
📤Output Arguments
Parameter Description
op a scalar nelson.indexing.IndexingOperation.
📄Description

nelson.indexing.IndexingOperation describes one indexing operation. It is passed to the parenReference/parenAssign, braceReference/braceAssign and dotReference/dotAssign methods of classes that derive from nelson.mixin.indexing.Redefines*. A chained expression is passed as a 1×N array of operations (one per level of the chain), so indexOp can be scalar or an array.

Properties: Type (a nelson.indexing.IndexingOperationType), Indices (cell array of the subscripts, for Paren/Brace) and Name (the field name, for Dot).

An IndexingOperation (scalar or array) can be applied to any value with the dynamic form value.(indexOp), which performs the corresponding subsref (read) or subsasgn (write) chain. This is the recommended way to forward the received chain from a hook, for example obj.Data.(indexOp).

💡Examples
Build a paren indexing operation.
op = nelson.indexing.IndexingOperation('Paren', {2});
char(op.Type)
op.Indices{1}
Apply an operation array to a value with the dynamic form value.(indexOp).
data = struct('f', {[1 2 3], [4 5 6 7]});
chain = [nelson.indexing.IndexingOperation('Paren', {2}), ...
         nelson.indexing.IndexingOperation('Dot', {}, 'f')];
data.(chain)   % same as data(2).f
🔗See Also
nelson.indexing.IndexingOperationTypenelson.mixin.indexing.RedefinesParen
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub