I have an n-dimensional array, VV, which I would like to maximize along all dimensions for each element in the first dimension. I would also like to obtain the associated linear indices so that I can evaluate related arrays at those locations. I have to do this a large amount of times, so I need to figure out a way to do this without a for loop.
Here is an example for an n=3 dimensional array, but with a loop:
Vtemp = squeeze(VV(ii,:,:));
[V(ii) I(ii)] = max(Vtemp(:));
[~,ind] = ismember(V,VV);
Any help would be appreciated.