minimum of a 3D matrix
Ältere Kommentare anzeigen
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!
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 31 Okt. 2012
Try this:
minOfPlane = min(min(M(:,:, t)))
9 Kommentare
Qian
am 31 Okt. 2012
Walter Roberson
am 31 Okt. 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
am 31 Okt. 2012
Walter Roberson
am 31 Okt. 2012
[minM idx] = min(reshape(M(:,:,1),[],1)); %first plane only
or, for all simultaneously,
[minM idx] = min(reshape(M, [], size(M,3)));
Qian
am 31 Okt. 2012
Walter Roberson
am 31 Okt. 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
am 31 Okt. 2012
Andrei Bobrov
am 31 Okt. 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
am 31 Okt. 2012
Ah yes, the 0:2 I used should be 0:size(M,3)-1
Kategorien
Mehr zu Numbers and Precision finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!