Navigation

Operators and Keywords

Function List:

C++ API

: subsasgn (val, idx, rhs)

Perform the subscripted assignment operation 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 set the two first columns of a 3-by-3 matrix to zero.

val = magic (3);
idx.type = "()";
idx.subs = {":", 1:2};
subsasgn (val, idx, 0)
    ⇒  [ 0   0   6
          0   0   7
          0   0   2 ]

Note that this is the same as writing val(:, 1:2) = 0.

If idx is an empty structure array with fields ‘type’ and ‘subs’, return rhs.

See also: subsref, substruct, optimize_subsasgn_calls.

Package: octave