User`s guide
R2014a
3-6
V = validatestring('',{'Cantor','','Koch'})
V =
''
In versions of MATLAB prior to R2014a, the call to validatestring results in an error.
Compatibility Considerations
Change code that relies expects an error when testing the validity of an empty string.
matlab.lang.makeValidName and
matlab.lang.makeUniqueStrings functions for constructing unique
MATLAB identifiers
The matlab.lang.makeValidName function returns valid MATLAB identifiers from input
strings. The output names are not guaranteed to be unique. For example,
S = {'Item#','Item#','Price/Unit','1st order','Contact'};
N = matlab.lang.makeValidName(S)
N =
'Item_' 'Item_' 'Price_Unit' 'x1stOrder' 'Contact'
The matlab.lang.makeUniqueStrings function returns unique strings from input strings.
For example,
S = {'coffee' 'tea' 'coffee' 'water' 'coffee'};
U = matlab.lang.makeUniqueStrings(S)
U =
'coffee' 'tea' 'coffee_1' 'water' 'coffee_2'
Use these two new functions together to ensure that output strings are valid and unique
MATLAB identifiers. For example,
S = {'Item#','Item#','Price/Unit','1st order','Contact'};
N = matlab.lang.makeValidName(S);
U = matlab.lang.makeUniqueStrings(N,{},namelengthmax)
U =