iskeyword
Determine whether input isMATLABkeyword
Syntax
tf = iskeyword(txt)
iskeyword
Description
tf = iskeyword(txt)
returns logical1
(true
) if the character vector or string scalartxt
is a keyword in the MATLAB®language and logical0
(false
) otherwise. MATLAB keywords cannot be used as variable names.
iskeyword
returns a list of all MATLAB keywords.
Examples
To test if the wordwhile
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'
Introduced before R2006a