I have a matrix of the form:
a =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
column 1 & 2 represent x,y positions while col 3-5 represent intensity. I obtained the maximum and index of the intensity for each position from [M,I] =max(a(:,3:5),[],1). I am struggling with how to obtain the x,y positions corresponding to each maximum intensity. Any help would be appreciated. Thanks.

2 件のコメント

madhan ravi
madhan ravi 2019 年 2 月 20 日
explicitly write your desired output
Manu Mensa
Manu Mensa 2019 年 2 月 20 日
Thank you very much.

サインインしてコメントする。

 採用された回答

madhan ravi
madhan ravi 2019 年 2 月 20 日

0 投票

x(I)
y(I)

4 件のコメント

Manu Mensa
Manu Mensa 2019 年 2 月 20 日
Sorry about this, i tried this but i only get one dimension position values. I require the output to be the x,y positions corresponding to the maximum values of the intensity. i.e output should be of the form:
11 18
10 12
4 6
madhan ravi
madhan ravi 2019 年 2 月 21 日
x=a(:,1);
y=b(:,2);
Result=[x(I) y(I)]
Stephen23
Stephen23 2019 年 2 月 21 日
編集済み: Stephen23 2019 年 2 月 21 日
Or without intermediate variables:
>> [M,I] = max(a(:,3:5),[],1);
>> XY = [a(I,1),a(I,2)]
XY =
11 18
10 12
4 6
Manu Mensa
Manu Mensa 2019 年 2 月 21 日
Thank you all very much. It worked.

サインインしてコメントする。

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2019 年 2 月 20 日

0 投票

maxxy = zeros(3, 2) ; % pre-allocation
for k = 1:3
[~, r] = max(M(:, k+2)) ; % row of maximum value in column k
maxxy(k, :) = M(r, [1 2]) ;
end

1 件のコメント

Manu Mensa
Manu Mensa 2019 年 2 月 21 日
Thank youy very much.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2019 年 2 月 20 日

コメント済み:

2019 年 2 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by