iskeyword — Test MATLAB reserved keywords or list all keywords.

iskeyword(s) returns true when s is a MATLAB reserved keyword. iskeyword with no inputs returns a cell column containing the full keyword list as character vectors.

Syntax

tf = iskeyword(s)
k = iskeyword

Inputs

NameTypeRequiredDefaultDescription
sStringScalarYesString scalar or character vector to test.

Returns

NameTypeDescription
tfLogicalArrayTrue when the text is a MATLAB keyword.
kAnyCell column of MATLAB keyword character vectors.

Errors

IdentifierWhenMessage
RunMat:iskeyword:InvalidArgumentMore than one input argument is supplied.iskeyword: expected zero or one input argument
RunMat:iskeyword:InvalidTextInput is not a string scalar or character vector.iskeyword: input must be a string scalar or character vector

How iskeyword works

  • Accepts a string scalar or character vector for the predicate form.
  • Rejects non-text inputs and nonscalar string arrays.
  • The keyword list is shared with isvarname, so reserved words such as for, end, classdef, and parfor cannot be valid variable names.
  • The result of iskeyword(s) is a host logical scalar. The result of iskeyword is a cell column of character row vectors.

Examples

Test a reserved keyword

tf = iskeyword('for')

Expected output:

tf = logical(1)

Test ordinary text

tf = iskeyword("plot")

Expected output:

tf = logical(0)

Return all keywords

k = iskeyword

Expected output:

k = {'break'; 'case'; ...; 'while'}

Using iskeyword with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how iskeyword changes the result.

Run a small iskeyword example, explain the result, then change one input and compare the output.

FAQ

Does iskeyword accept string arrays?

Only string scalars are accepted. Multi-element string arrays are rejected so the predicate remains a scalar MATLAB-compatible query.

Is the comparison case-sensitive?

Yes. MATLAB keywords are lowercase language tokens, so iskeyword('for') is true while iskeyword('For') is false.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how iskeyword is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.