matlab.lang.makeUniqueStrings
- :
uniqstr =matlab.lang.makeUniqueStrings(str)¶ - :
uniqstr =matlab.lang.makeUniqueStrings(str, ex)¶ - :
uniqstr =matlab.lang.makeUniqueStrings(str, ex, maxlength)¶ - :
[uniqstr, ismodified] =matlab.lang.makeUniqueStrings(…)¶ -
Make every string in a list different from the others.
str is a single string or a cell array of strings, and uniqstr has the same type. Whenever a string repeats an earlier one, the later copy gets an underscore and a counter appended (
"name_1","name_2", …).ex may be a string or cell array of strings that the result must also avoid: a string in str that matches one of them is renamed as well. Alternatively ex may be an index vector or a logical mask into str that marks the elements to process; the remaining elements are left as they are and only serve as names to avoid.
maxlength caps the length of every output string. A string that would be too long is shortened before the suffix is added, and an error is raised if no unique name of that length can be found.
ismodified is a logical array, one entry per element of str, that is true where the string was changed.