Now that we have clear explanations, it's easy to compute the result of your algorithm.
As mentioned in my comments, I'm going to use the natural left-to-right indexing. You're free to permute the input and output with fliplr.
The following may not be the most efficient implementation in term of memory (it does a fair number of reallocation). It's a straightforward implementation of your algorithm:
permutationrule = [1 2 2 2 5 4]
permutated = ;
for idx = 1:numel(permutationrule)
insertionpoint = permutationrule(idx);
permutated = [permutated(1:insertionpoint-1), idx, permutated(insertionpoint:end)];
It's simple, permutationrule(idx) tells you where idx needs to be inserted in permutated. So you jut have to concatenate, the portion of permutated before the insertion point (i.e. permutated(1:insertionpoint-1)), the insertion (i.e. idx), and the portion of permutated from the insertion point to the end (i.e. permutated(insertionpoint:end)).