Let A
be the matrix then you can use
[B, I] = min(A, [], 3);
Where B
is the minimum values and I
contains the indices. If you are not interested in minimum values you can use
[~, I] = min(A, [], 3);
For you example
>> A(:,:,1) = [3 5 6; 1 4 2; 7 5 2];
>> A(:,:,2) = [1 8 2; 4 6 1; 9 2 5];
>> [B,I]=min(A, [], 3)
B =
1 5 2
1 4 1
7 2 2
I =
2 1 2
1 1 2
1 2 1