genvarname
- :
varname =genvarname(str)¶ - :
varname =genvarname(str, exclusions)¶ Construct valid variable names from the text str, which is a string or a cell array of strings.
Characters other than ASCII letters, digits and underscores become underscores (one underscore for each non-ASCII character), a name that does not begin with a letter gets an ‘x’ prepended, a keyword is turned into ‘x’ followed by the capitalised keyword, and names are cut to
namelengthmaxcharacters.No result equals a name in exclusions (a string or cell array of strings, compared case sensitively). Where there is a clash, the smallest positive integer that makes the name unique is appended. The names of a cell array are produced in order, and each one is excluded for the names that follow it.