Consider a 3D array. Call it A1. Each dimension belongs to a variable (d1=>X1, d2=>x2, d3=>X3). Each element (i,j,k) of the A1 array specifies the transition of variable X1 from one period to the next.
I fact X1 is an index variable/vector with length equal to dimension 1 of A1, X2 is an index variable with length equal to the dimension 2 of A1, and X3 is an index variable with length equal to dimension 3 of A1.
There N individuals. Each individual n is described at any period t by 3 values of the 3 variables, Index(n,t) = (x1(n,t),x2(n,t),x3(n,t)). These 3 values are indices into the array A1, and when they are plugged into A1 produce the new value of x1(n,t+1) (itself an index).
The process is repeated for 2 other arrays, A2 and A3, which given the above input vector Index(n,t) produce the new values for individual n of x2(n,t+1) and x3(n,t+1).
What I need is a one line way to extract x1(n=1:N,t+1), for all N individuals simultaneously, using the A1 array, and 3 vectors Index(n=1:N,t) => x1(n=1:N,t) , x2(n=1:N,t) and x3(n=1:N,t)).
If I was working with 2 dimensions in A1, using a "diag" command  Indexout = diag(A1(index1in,index2in))  gives me this easily. But with 3 dimensions I am not sure how to write it so that I dont have to loop.
Thank you
Joao Ejarque
