


ONOFF2BOOL Substitutes 1 for 'on' and 0 for any other string.
BOOL = ONOFF2BOOL(ONOFF) returns logical 1 if ONOFF is equal to the
string 'on' and logical 0 otherwise.
BOOL2ONOFF and ONOFF2BOOL improve readability for Matlab settings
(e.g., Handle Graphics properties) that use the strings 'on' and 'off'.
Example:
if (onoff2bool(get(handle,'Enable'))), ...
is equivalent to
if (strcmp(get(handle, 'Enable'), 'on')), ...
See also BOOL2ONOFF.

0001 function bool = onoff2bool(onoff) 0002 %ONOFF2BOOL Substitutes 1 for 'on' and 0 for any other string. 0003 % BOOL = ONOFF2BOOL(ONOFF) returns logical 1 if ONOFF is equal to the 0004 % string 'on' and logical 0 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 % if (onoff2bool(get(handle,'Enable'))), ... 0011 % is equivalent to 0012 % if (strcmp(get(handle, 'Enable'), 'on')), ... 0013 % 0014 % See also BOOL2ONOFF. 0015 0016 bool = strcmp(onoff, 'on');