fn_switch

Contents

Syntax

y = fn_switch(x,y_true,[x2,y_true2,[...]]y_false)
y = fn_switch(x,case1,y1,case2,y2,..,casen,yn[,ydefault])
y = fn_switch(true|false|'on'|'off')
y = fn_switch(true|false|'on'|'off','logical'|'on/off')
y = fn_switch('on|off','toggle')
y = fn_switch(y,y_defaultifempty)

Description

The 2 first cases are general prototypes: the functions recognize which
to use according to whether x is logical and scalar
MAKE SURE THAT X IS SCALAR AND LOGICAL IF YOU WANT TO USE THE FIRST FORM!
'case1', 'case2', etc.. can be any Matlab variable to which x is compared
but if they are cell arrays, x is compared to each of their elements.
The other cases are specialized shortcuts dedicated (except the last one)
to conversions between logical values and the strings 'on' or 'off'.
See also fn_cast

Source

Thomas Deneux

Copyright 2005-2017