minimum of a 3D matrix
Afficher commentaires plus anciens
M=rand(2,2,3)
[minM idx] = min(M(:));
[n m t] = ind2sub(size(M),idx)
minM
M(n,m,t)
I know this will give the minimum of the M matrix.
However, I want minimum value only for each M(:,:,i) part.
Is there anyway to do that?
Thanks in advance!
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 31 Oct 2012
Try this:
minOfPlane = min(min(M(:,:, t)))
9 commentaires
Qian
le 31 Oct 2012
Walter Roberson
le 31 Oct 2012
If you want to do all the planes simultaneously, min(min(M)) . You might want to squeeze() the result to make it a column vector.
Qian
le 31 Oct 2012
Walter Roberson
le 31 Oct 2012
[minM idx] = min(reshape(M(:,:,1),[],1)); %first plane only
or, for all simultaneously,
[minM idx] = min(reshape(M, [], size(M,3)));
Qian
le 31 Oct 2012
Walter Roberson
le 31 Oct 2012
[minM idx] = min(reshape(M, [], size(M,3)));
idx = idx + (size(M,1)*size(M,2)).*(0:2);
[n m t] = ind2sub(size(M), idx);
Qian
le 31 Oct 2012
Andrei Bobrov
le 31 Oct 2012
[v, i1] = min(reshape(M,[],size(M,3)));
min_idx_m_n_t = [rem(i1-1,size(M,1))+1; ceil(i1/size(M,1)); 1:size(M,3)]';
Walter Roberson
le 31 Oct 2012
Ah yes, the 0:2 I used should be 0:size(M,3)-1
Catégories
En savoir plus sur Numbers and Precision dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!