Perform the subscripted element selection operation on val according to the subscript specified by idx.
The subscript idx must be a structure array with fields ‘type’
and ‘subs’. Valid values for ‘type’ are "()"
,
"{}"
, and "."
. The ‘subs’ field may be either
":"
or a cell array of index values.
The following example shows how to extract the first two columns of a matrix
val = magic (3) ⇒ val = [ 8 1 6 3 5 7 4 9 2 ] idx.type = "()"; idx.subs = {":", 1:2}; subsref (val, idx) ⇒ [ 8 1 3 5 4 9 ]
Note that this is the same as writing val(:, 1:2)
.
If idx is an empty structure array with fields ‘type’ and ‘subs’, return val.
See also: subsasgn, substruct.
Package: octave