Min of each row of a matrix and their indexes

43 次查看(过去 30 天)
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?

采纳的回答

Andrei Bobrov
Andrei Bobrov 2016-8-21
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(:)]

更多回答(1 个)

Geoff Hayes
Geoff Hayes 2016-8-21
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)

类别

Help CenterFile Exchange 中查找有关 Point Cloud Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by