Navigation

Operators and Keywords

Function List:

C++ API

: merge (mask, tval, fval)
: ifelse (mask, tval, fval)

Merge elements of true_val and false_val, depending on the value of mask.

If mask is a logical scalar, the other two arguments can be arbitrary values. Otherwise, mask must be a logical array, and tval, fval should be arrays of matching class, or cell arrays. In the scalar mask case, tval is returned if mask is true, otherwise fval is returned.

In the array mask case, both tval and fval must be either scalars or arrays with dimensions equal to mask. The result is constructed as follows:

result(mask) = tval(mask);
result(! mask) = fval(! mask);

mask can also be arbitrary numeric type, in which case it is first converted to logical.

See also: logical, diff.

Package: octave