R = iskeyword stores in the cell array
R the reserved words of the MATLAB language.
tf = iskeyword(str) determines if
str is a reserved word and stores the result in the logical variable
% Get all reserved words resultExample1 = iskeyword;
resultExample1 = 'break' 'case' 'catch' 'classdef' 'continue' 'else' 'elseif' 'end' 'for' 'function' 'global' 'if' 'otherwise' 'parfor' 'persistent' 'return' 'spmd' 'switch' 'try' 'while'
% Check if 'while' is a reserved word resultExample2 = iskeyword('while');
resultExample2 = 1
% Check if 'name' is a reserved word resultExample3 = iskeyword('name');
resultExample3 = 0
I recommend the following books to learn more on how reserved words are treated in MATLAB and other programming languages:
This book was the winner of a 2017 Textbook Excellence Award. The first chapter explains MATLAB reserved words, identifiers, and other introductory topics.
Concepts of Programming Languages (11th Edition)
This book covers the fundamental topics of programming languages. Chapter 4 describes what reserved words, identifiers, variables, bindings, and scopes are in programming languages.
I also recommend the following page in the MATLAB help documentation, and the other tutorials in this series.
I hope you have learned how to get the reserved words of the MATLAB language. The source code developed in this tutorial is available at this page.