I have a multidimensional array, Data
, and a 1xn
vector Location
whose elements correspond to the indexes of a specific point I wish to access inside the array Data
.
Therefore, the number of elements in vector Location
is always equal to the dimension of the multidimensional array Data
. (If length(Location) = n, then dim(Data)=n
).
So for example, if Location = [4 0 9 3]
, then the point I am trying to access in Data
would be: result = Data(4,0,9,3)
.
If the dimension of Data
would be fixed, I could simply do (if say, n=4
):
result = Data(Location(1,1), Location(1,2), Location(1,3), Location(1,4));
However, in my problem, the dimension of Data
(and therefore the length of Location
) change.
This makes accessing Data
more complicated and I'm a bit lost so as how to do this.
How can I determine the point in Data
I am trying to access ?
If possible, I would prefer a solution that doesn't use any loops, but this might be impossible, so if you have a solution based on a loop, please propose it anyway!