Take mininum over only two dimensions of 4-d array

I have a 4-D array array=[i,j,k,l]. For given values of i and j, I would like to know the minimum value in the array for any k or l, as well as the values of k and l for this value.
Basically I'd like something like [min_value, min_k, min_l]=min (array,[],3:4)
but min, as far as I can tell, doesn't take minima over multiple dimensions.
Thanks in advance.

 채택된 답변

James Tursa
James Tursa 2013년 5월 3일

1 개 추천

sub_array = array(i,j,:,:);
[V X] = min(sub_array(:));
[I J K L] = ind2sub(size(sub_array),X);
The minimum value in the specified sub array will be V, and the indexes for the 3rd and 4th dimensions will be K and L.

추가 답변 (2개)

Iman Ansari
Iman Ansari 2013년 5월 3일

0 개 추천

Hi.
R=reshape(1:16,[2 2 2 2]);
M=min(min(R,[],4),[],3);
Andrei Bobrov
Andrei Bobrov 2013년 5월 3일

0 개 추천

a = randi(10,4,5,2,3); % eg
s = size(a);
a1 = reshape(a,s(1),s(2),[]);
[m1,i1] = min(a1,[],3);
k = mod(i1-1,s(3))+1;
l = ceil(i1/s(3));

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

태그

질문:

Eva
2013년 5월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by