


BOOL2ONOFF Substitutes 'on' for non-zero and 'off' for zero input.
ONOFF = BOOL2ONOFF(BOOL) returns the string 'on' if BOOL evaluates as
logically true or the string 'off' otherwise.
BOOL2ONOFF and ONOFF2BOOL improve readability for Matlab settings
(e.g., Handle Graphics properties) that use the strings 'on' and 'off'.
Example:
set(handle, 'Enable', bool2onoff(X==Y))
is equivalent to
if (X==Y), e = 'on'; else, e = 'off'; set(handle, 'Enable', e);
See also ONOFF2BOOL.

0001 function onoff = bool2onoff(bool) 0002 %BOOL2ONOFF Substitutes 'on' for non-zero and 'off' for zero input. 0003 % ONOFF = BOOL2ONOFF(BOOL) returns the string 'on' if BOOL evaluates as 0004 % logically true or the string 'off' otherwise. 0005 % 0006 % BOOL2ONOFF and ONOFF2BOOL improve readability for Matlab settings 0007 % (e.g., Handle Graphics properties) that use the strings 'on' and 'off'. 0008 % 0009 % Example: 0010 % set(handle, 'Enable', bool2onoff(X==Y)) 0011 % is equivalent to 0012 % if (X==Y), e = 'on'; else, e = 'off'; set(handle, 'Enable', e); 0013 % 0014 % See also ONOFF2BOOL. 0015 0016 if (bool), onoff = 'on'; else onoff = 'off'; end;