MATLAB: How can i manipulate matrix like this

matrixmatrix manipulation

EDIT: I have solved the problem with using if-end loop, but if you share alternative solutions if you have, i will be very happy. Thanks.
Hi everbody,
I have a matrix like under the this text:
A=[1 1 2 2 3 3 4 4 5 5 6 6 1 1 2 2 3 3 4 4 5 5 1 1 2 2 3 3 4 4 5 5 ]
To transform the some numbers, which were written with bold type, to [4 3 2]; what kind of a code can be written?
If the numbers decrease from 6 to 1 or 5 to 1, some values should be change.
Modified matrix should be:
A=[1 1 2 2 3 3 4 4 5 4 3 2 1 1 2 2 3 3 4 4 3 2 1 1 2 2 3 3 4 4 5 5 ];
after the operation.
Thanks for answers.

Best Answer

If there is a small number of possible repleacements only -perhaps 10-, use strrep:
toRep = [5 6 6 1];
Rep = [4 3 2 1];
data = strrep(data, toRep, Rep);
If the problem concerns many different patterns, define the pattern exactly at first. Then a general algorithm can be found.