From: Tom Toner on
Here is my solution,

str0 = '0010210020010000200000012102'
[mstr,sstr] = regexp(str0, '1[0]+2', 'match', 'split');
mstr1 = regexprep(mstr,'0','3');
str1 = [sstr; [mstr1 {''}]];
str = [str1{:}]

Results:
str0 =
0010210020010000200000012102
str =
0013213320013333200000012132

However, I was wondering if there were better solutions.

Thanks,