Consider the string:
str = 'text text [[i]] text text [[i]]'
The [[i]] string should be replaced by a random integer, say 1 for the first [[i]] and 5 for the second [[i]]. Is there a way to achieve this in Matlab without relying on the split command?
The classical
newstrreg = regexprep(str, '\[\[i\]\]',num2str(rand(1)))
will replace all [[i]] in the same string by the same randomized value, which I do not want.