MATLAB: How to retrieve Matrix every three numbers

matrix index

A = randi(10,10,5);
A =
2 8 7 1 4
9 8 8 1 7
4 8 2 8 8
3 3 2 10 6
8 7 6 7 8
1 6 5 2 3
1 4 9 8 8
7 1 8 2 10
7 8 8 2 9
6 4 1 7 1
In this case how can i retrieve in for loop
1. 2, 8
2. 7, 1
3. 4
Thanks

Best Answer

nc = size(A,2);
for K = 1 : 2 : nc
if K == nc
result = A(1,K);
else
result = A(1, K:K+1);
end
end