matlab.lang.makeUniqueStrings
Construct unique strings from input strings
Syntax
Description
U = matlab.lang。makeUniqueStrings(
constructs strings or character vectors that are unique withinS
,excludedStrings
)U
and with respect toexcludedStrings
. ThemakeUniqueStrings
function does not checkexcludedStrings
for uniqueness.
U = matlab.lang。makeUniqueStrings(
specifies the subset ofS
,whichStringsIdx
)S
to make unique within the entire set.makeUniqueStrings
makes the elements inS(whichStringsIdx)
unique among themselves and with respect to the remaining elements.makeUniqueStrings
returns the remaining elements unmodified inU
. Use this syntax when you have an string array or an array of character vectors, and need to check that only some elements are unique.
U = matlab.lang。makeUniqueStrings(
specifies the maximum length,S
,___,maxStringLength
)maxStringLength
, of elements inU
. IfmakeUniqueStrings
cannot make elements inS
unique without exceedingmaxStringLength
, it returns an error. You can use this syntax with any of the input arguments of the previous syntaxes.
Examples
Input Arguments
Output Arguments
Tips
To ensure that input values are valid and unique, use
matlab.lang.makeValidName
beforematlab.lang.makeUniqueStrings
.S = {'my.Name','my_Name','my_Name'}; validValues = matlab.lang.makeValidName(S) validUniqueValues = matlab.lang.makeUniqueStrings(validValues,...{},namelengthmax)
validValues = 'my_Name' 'my_Name' 'my_Name' validUniqueValues = 'my_Name' 'my_Name_1' 'my_Name_2'