isyes.m

来自「实现地震勘探中」· M 代码 · 共 40 行

M
40
字号
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 + =
减小字号Ctrl + -
显示快捷键?