MATLAB Function Reference    

Determine if item is a valid variable name



tf = isvarname 'str' returns logical true (1) if the string, str, is a valid MATLAB variable name and logical false (0) 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

isglobal, iskeyword, namelengthmax, is*

  isvalid (timer)