I think I understand now. MATLAB is great for matrices, so indexing them is intuitive. For some matrix a with i rows and j columns, to access the element in position (i,j) you can call A(i,j). More relevant to your question, to do operations using matrices in a loop we can stack k 2D matrices in a 3rd dimension so A with k 2D matrices that have i rows and j columns. To access the k'th matrix we can call A(:,:,k). The colon in MATLAB means all elements in that direction and the argument order is always (rows,columns,other).
Example: Say I want to get the rank of 20 different 50 by 100 matrices that I have stored in a 50x100x20 matrix called A. In MATLAB we can do,
for i=1:20
R(i)=rank(A(:,:,i));
end
which will loop through and store the results in R.
Thanks a lot.This is what I have already done,but let me make it more clear. I want to perform the algorithm suggested in the picture; obtaining a matrix having two indices whose diagonal arrays get updated one by one.