Skip to content

ifelse

general · scripts/general/ifelse.m

: m = ifelse (mask, tval, fval)

Select between tval and fval according to mask.

Octave-compatible public name wrapping __ifelse__ (alias of __merge__). A scalar mask returns one of the two values unchanged; an array mask picks tval where true and fval elsewhere.

Clean-room Octave-compat helper. MATLAB-valid % comments so the file parses under MATLAB-strict user addpath as well as under the shipped scripts tree. MATLAB has no ifelse. The Octave synonym merge is intentionally not shipped as a core public name here: MATLAB and several Nexus toolboxes already use merge for other APIs. Octave-ported code should call ifelse.