matlab.lang.makeUniqueStrings
Construct unique strings from input strings
Syntax
Description
U = matlab.lang.makeUniqueStrings(
constructs
strings or character vectors that are unique within S
,excludedStrings
)U
and
with respect to excludedStrings
. The makeUniqueStrings
function
does not check excludedStrings
for uniqueness.
U = matlab.lang.makeUniqueStrings(
specifies
the subset of S
,whichStringsIdx
)S
to make unique within the entire
set. makeUniqueStrings
makes the elements in S(whichStringsIdx)
unique
among themselves and with respect to the remaining elements. makeUniqueStrings
returns
the remaining elements unmodified in U
. 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
in U
. If makeUniqueStrings
cannot
make elements in S
unique without exceeding maxStringLength
,
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'
Version History
Introduced in R2014a