Returning an Entire Row Based on the Max in a Column

1 vue (au cours des 30 derniers jours)
Erick Sirois
Erick Sirois le 27 Jan 2020
Commenté : Erick Sirois le 27 Jan 2020
Hi.
I'm trying to get the entire row based on the max value of a column. For example:
x = [5 6 6 9
7 3 2 4
3 12 8 4]
Now say I want the entire row belonging to the column 2 maximum value. I should get the row with 3 12 8 4 because 12 is the max value in column 2.
Is there a way to do this? I've tried the help and searching here and other places but cant seem to find it.

Réponse acceptée

Matt J
Matt J le 27 Jan 2020
[~,imax]=max(x(:,2));
out = x(imax,:)

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by