MATLAB: Reversing every second row in a matrix

flip

Hello!
I have a question regarding matrix transformation. The simplified version of what I have is:
1 2 3
4 5 6
7 8 9
10 11 12
etc
What I want is that every second row is reversed, so resulting in:
1 2 3
6 5 4
7 8 9
12 11 10
I have tried the flip-function, but as far as I found out that reverses every row. Any idea how to do this?
Thanks!

Best Answer

M = [ 1 2 3;
4 5 6;
7 8 9;
10 11 12];
M(2:2:end,:) = fliplr(M(2:2:end,:))