Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

iskeyword

Determine whether input is MATLAB keyword

Syntax

tf = iskeyword(txt)
iskeyword

Description

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.

Examples

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'

Introduced before R2006a

Was this topic helpful?