In MATLAB, I have a multidimensional array of floats, A
, with m
dimensions; that is, its entries can be referenced with A(n_1, n_2, ..., n_m)
.
I don't know if there is a good way to describe this using technical terms, so let me just use an example: if A
is a 4-dimensional array, then
A(:,:,1,:)
is a 1st cross section of A
in the 3rd coordinate. Similarly,
A(:,2,1,:)
would be the (2,1)th cross section of A
in the 2nd and 3rd coordinates.
So my general question is, given an A
whose dimensions are only determined at runtime, how do I reference the (k_1,...,k_j)
th cross section of A
in the (c_1,...,c_j)
coordinates, where the k
's and c
's are also variables?