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

    %% Insert Substring After Position
% Create string arrays and specify positions to insert substrings.
%
% Create a string that contains a name.
str = string('James Maxwell')

%%
% Insert a substring after the fifth character.
newStr = insertAfter(str,5,' Clerk')
%%
% Insert substrings into each element of a string array. When you specify 
% different positions with numeric arrays, they must be the same size as the 
% input string array.
str = string({'James Maxwell';'Carl Gauss'})
newStr = insertAfter(str,[5;4],{' Clerk';' Friedrich'})