📄 isyes.m
字号:
function bool=isyes(bool)% Check if input argument is either 'yes', 'on', or the logical variable "true". % If this is the case the output variable is set to "true"; otherwise it % is set to "false". The case of the string is irrelevant.%% Written by: E. R.: October 6, 2006% Last updated: February 18, 2008: More error checking%% bool=isyes(bool)% INPUT% bool logical variable or a string% OUTPUT% bool logical variable; true if input argument is the string 'yes' % (case insensitive) or the logical variable "true".% otherwise it is false% UPDATE HISTORY% October 26, 2007: The string 'on' is allowed and results in "true"if islogical(bool) returnelseif ischar(bool) bool0=bool; bool=ismember(lower(bool),{'yes','on'}); if bool return else bool=~ismember(lower(bool0),{'no','off'}); if bool error([' illegal argument to "isyes":', bool0]) end end else error('The input argument must be a logical variable or a string.')end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -