Determine whether input is MATLAB keyword
tf = iskeyword(txt)
iskeyword
tf = iskeyword(txt)
returns logical 1
(true
) if the character vector or string scalar txt
is a keyword in the MATLAB® language and logical 0
(false
) otherwise. MATLAB keywords cannot be used as variable names.
iskeyword
returns a list
of all MATLAB keywords.
To test if the word while
is a MATLAB keyword,
iskeyword('while') ans = 1
To obtain a list of all MATLAB keywords,
iskeyword 'break' 'case' 'catch' 'classdef' 'continue' 'else' 'elseif' 'end' 'for' 'function' 'global' 'if' 'otherwise' 'parfor' 'persistent' 'return' 'spmd' 'switch' 'try' 'while'
is*
| isvarname
| matlab.lang.makeUniqueStrings
| matlab.lang.makeValidName