%% Construct Unique Character Vectors with Maximum Length
% Create an array from S where the first three elements are unique and the maximum length of each string is 5.

S = {'sampleData' 'sampleData' 'sampleData' 'sampleData'};
U = matlab.lang.makeUniqueStrings(S, 1:3, 5)

% The first element is truncated to 5 characters. The second and third elements are truncated to 3 characters to allow makeUniqueStrings to append an underscore and number, and still not exceed 5 characters.
% Copyright 2012 The MathWorks, Inc.