I have a 3D array that looks like this:
edges = round(rand(20,20,20)));
I then create a random list of indices as follows:
indices = floor(rand(10000,3)*(19))+1;
So if I try to use the first row of the indices 2D array to access an element in the edges array, I do:
>>> edges(indices(1,1),indices(1,2),indices(1,3))
>>> ans = 1
I figured, if I wanted to get the value of edges at all of the index positions, I could do
>>> edges(indices)
but that returns an 10000 by 3 matrix. I would expect a 10000 by 1 matrix with values of edges at positions specified by each row of indices. What is going on here, and is there a way to get the values I want without using any for loops?
sub2indandind2sub