How can I use the indices returned from ‘min’ function in matlab to retrieve its data in a 3D matrix on third dimension?
for example, I have the code below:
%a is a 3D matrix
[res, index] = min(a, [], 3);
An I want to access the min elements using index, something like:
a(index);
NOTE: I want not to use res variable
to get them all:
More general approach
You can also reshape the result to get it in the same dimensions as the original matrix (with omission of the minimized dimension):
Works for any size of data matrix or any value
dim_min(as long as1<=dim_min<=ndims(a)of course)