| MATLAB Function Reference | ![]() |
Test if string is a valid variable name
Syntax
isvarname 's'
R = isvarname('s')
Description
isvarname 's'
returns a 1 if string, s, is a valid MATLAB variable name. Returns 0, otherwise. A valid variable name is a character string of letters, digits, and underscores, totaling not more than 32 characters and beginning with a letter.
R = isvarname('s')
returns a 1 in R if string, s, is a valid variable name.
Examples
You can use isvarname without parenthesis if you pass a single string argument. If you are building strings from various pieces, place the construction in parenthesis.
isvarname foo
ans =
1
isvarname 'Monday 23'
ans =
0
d = date;
isvarname(['Monday_',d(1:2)])
ans =
1
See Also
iskeyword, is*
| isvalid | j | ![]() |