MATLAB: Iterate through two matrices and get the item with the same index

indexingiterationmatrices

Hello,
I think this is a very simple problem. I have two matrices e.g.
A =
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
B =
5 5 5 5
6 6 6 6
7 7 7 7
9 9 9 9
Now I need for Matrix A the first index and for the Matrix B the same index, then the second index of A and the second index of B and so on. But i dont know how i can solve this in a double for loop.
I need the item at the index not just the index.
Hope u can help me. Thanks

Best Answer

for ii = 1:numel(A)
Aii = A(ii)
Bii = B(ii)
do_whatever_with(Aii,Bii)
end