The best way to explain what I'm trying to do is with an example. Say I have the following 2*2*3 matrix.
I want to construct a new 2D matrix (call is Amax) whose every (ith,jth) element is the maximum among the 2D matrices' elements of the original 3D matrix. For the above example, the new matrix Amax should be
Also, I need to know which 3rd dimension of the original 3D matrix the elements in Amax came from. So I need a second 2D matrix (call is INDEX) whose elements are the 3rd dimension of the original 3D matrix. For the above example, the new matrix INDEX should be
I don't what to use for loops, as the size of my 3D matrix is large. I need to vectorize the above operation.
thank you in advanced Ahmad