Return matrix of maximum values

3 vues (au cours des 30 derniers jours)
Manu Mensa
Manu Mensa le 20 Fév 2019
Commenté : Manu Mensa le 21 Fév 2019
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 commentaires
madhan ravi
madhan ravi le 20 Fév 2019
explicitly write your desired output
Manu Mensa
Manu Mensa le 20 Fév 2019
Thank you very much.

Connectez-vous pour commenter.

Réponse acceptée

madhan ravi
madhan ravi le 20 Fév 2019
  4 commentaires
Stephen23
Stephen23 le 21 Fév 2019
Modifié(e) : Stephen23 le 21 Fév 2019
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 le 21 Fév 2019
Thank you all very much. It worked.

Connectez-vous pour commenter.

Plus de réponses (1)

Jos (10584)
Jos (10584) le 20 Fév 2019
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 commentaire
Manu Mensa
Manu Mensa le 21 Fév 2019
Thank youy very much.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by