www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ConstructUniqueStringsExample.m

    %% Construct Unique Character Vectors  

%% 
% Create a cell array of names and make each element unique. 
S = {'John' 'Sue' 'Nick' 'John' 'Campion' 'John' 'Jason'};
U = matlab.lang.makeUniqueStrings(S) 

%%
% The |makeUniqueStrings| function appends the duplicate names in elements
% 3 and 5 with underscores and incrementing numbers.