Min of each row of a matrix and their indexes
43 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Babak MJ
am 21 Aug. 2016
Beantwortet: Andrei Bobrov
am 21 Aug. 2016
I have the topography data in which I introduced X, Y, Z as follows. How can I find min for each row of Z data and find their X and Y value?
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 21 Aug. 2016
X=[11 13 15]
Y=[43 45 47]
Z = [27 25 21;35 38 37 ;42 47 49]
[~,ii] = min(Z,[],2)
out = [X(ii)',Y(:)]
0 Kommentare
Weitere Antworten (1)
Geoff Hayes
am 21 Aug. 2016
Babak - if you want to find the minimum of each row of Z then use min as follows
>> Z = [27 25 21; 35 38 37; 42 47 49];
>> min(Z,[],2)
ans =
21
35
42
To get the index of each of the above then do
>> [minValues, minIndices] = min(Z,[],2)
minValues =
21
35
42
minIndices =
3
1
1
Presumably, your x and y coordinates for these values would then be
X(minIndices)
Y(minIndices)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Point Cloud Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!