MATLAB Function Reference Previous page   Next Page

Determine if input is valid variable name



tf = isvarname 'str' returns logical 1 (true) if the string str is a valid MATLAB variable name and logical 0 (false) otherwise. A valid variable name is a character string of letters, digits, and underscores, totaling not more than namelengthmax characters and beginning with a letter.

isvarname str uses the MATLAB command format.


This variable name is valid:

This one is not because it starts with a number:

If you are building strings from various pieces, place the construction in parentheses.

See Also

genvarname, isglobal, iskeyword, namelengthmax, is*

Previous page  isvalid (timer) isvector Next page

© 1994-2005 The MathWorks, Inc.