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
Determine If Input Is MATLAB Keyword
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)
Query MATLAB Keywords
Get a list of all MATLAB keywords.
k = 20x1 cell {'break' } {'case' } {'catch' } {'classdef' } {'continue' } {'else' } {'elseif' } {'end' } {'for' } {'function' } {'global' } {'if' } {'otherwise' } {'parfor' } {'persistent'} {'return' } {'spmd' } {'switch' } {'try' } {'while' }
Input Arguments
s
— Potential MATLAB keyword
string scalar | character vector
Potential MATLAB keyword, specified as a string scalar or character vector.
Output Arguments
tf
— True or false result
1 | 0
True or false result, returned as a 1
or0
of data type logical
.
k
— MATLAB keywords
cell array of character vectors
MATLAB keywords, returned as a cell array of character vectors.
More About
Keywords
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
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced before R2006a