| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
tf = isvarname('str')
isvarname str
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.
MATLAB keywords are not valid variable names. Type the command iskeyword with no input arguments to see a list of MATLAB keywords.
isvarname str uses the MATLAB command format.
This variable name is valid:
isvarname foo ans = 1
This one is not because it starts with a number:
isvarname 8th_column ans = 0
If you are building strings from various pieces, place the construction in parentheses.
d = date; isvarname(['Monday_', d(1:2)]) ans = 1
genvarname, isglobal, iskeyword, namelengthmax, is*
![]() | isvalid (timer) | isvector | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |