MATLAB: Alternating equations every other row

subtraction

I have A= [3 2 1, 3 8 2, 3 9 2, 9 5 1, 3 8 3, 7 4 2]
For the first row I would like to subtraction Column 2 from Column 1, then for row I want to subtract Column 1 from Column 2. I want these two equations to alternate when going through the rows. In the end I want something that looks like this:
B= [1, 5, -6, -4, -5, 3]
Thanks!

Best Answer

B = diff(A(:,[1,2]),1,2).*(-1).^(1:size(A,1))'