MATLAB: get index of minima in 3D array -
i have little question matlab.
i have 3d-array each 2d-layer picture. need "third" index (=the number of layer) of lowest value each pixel in array. @ end want have 2d array have index of these lowest values.
an example:
3d array these 2 2d-layers:
layer 1:
3-5-6 1-4-2 7-5-2 layer 2:
1-8-2 4-6-1 9-2-5 the result should following array:
2-1-2 1-1-2 1-2-1 i hope can see want achieve, sorry bad english, cannot express problem in words...
thank help.
let a matrix can use
[b, i] = min(a, [], 3); where b minimum values , i contains indices. if not interested in minimum values can use
[~, i] = min(a, [], 3); for 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 = 2 1 2 1 1 2 1 2 1
Comments
Post a Comment