Min of each row of a matrix and their indexes

10 ビュー (過去 30 日間)
Babak MJ
Babak MJ 2016 年 8 月 21 日
回答済み: Andrei Bobrov 2016 年 8 月 21 日
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 Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by