iskeyword - Determine if input is MATLAB keyword - MATLAB (original) (raw)
Main Content
Determine if input is MATLAB keyword
Syntax
Description
[tf](#mw%5F551ea6f9-d054-4b62-bad7-c05423821ed3) = iskeyword([s](#mw%5F478ca915-30aa-4538-b2ba-3555f0ebd2c2))
returns logical 1
(true
) if the input is a keyword in the MATLAB® language and logical 0
(false
) otherwise. For more information about MATLAB keywords, see Keywords.
[k](#mw%5F0bfd70e2-ce57-4b4d-9b72-bb1877180c3d) = iskeyword
returns a list of all MATLAB keywords.
Examples
Test if the word while
is a MATLAB keyword.
s = "while"; tf = iskeyword(s)
Test if the word myStr
is a MATLAB keyword.
s2 = "myStr"; tf = iskeyword(s2)
Get a list of all MATLAB keywords.
k = 20×1 cell {'break' } {'case' } {'catch' } {'classdef' } {'continue' } {'else' } {'elseif' } {'end' } {'for' } {'function' } {'global' } {'if' } {'otherwise' } {'parfor' } {'persistent'} {'return' } {'spmd' } {'switch' } {'try' } {'while' }
Input Arguments
Potential MATLAB keyword, specified as a string scalar or character vector.
Output Arguments
True or false result, returned as a 1
or0
of data type logical
.
MATLAB keywords, returned as a cell array of character vectors.
More About
Keywords are identifiers in MATLAB code that have a reserved meaning, so they cannot be used as variable names. See Query MATLAB Keywords for a list of all MATLAB keywords.
Extended Capabilities
Version History
Introduced before R2006a