Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

how to find the position of the max componunt

1 vue (au cours des 30 derniers jours)
Doyoung Kim
Doyoung Kim le 12 Sep 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
for exemple if i have this matrix
1 0.5
2 0.2
3 0.4
4 0.7
5 0.6
left side is just the lebel to show the position. and I want to know the max value of the right side's components
in this case. [4 0.7 ]
0.7 for being the largest on left side and 4 for its position
and when I use max function, I only get [5 0.7] the max value of both side.
what should i do :(

Réponses (1)

Matt J
Matt J le 12 Sep 2020
Modifié(e) : Matt J le 12 Sep 2020
Call max() with two output arguments and only input the columns you are interested in getting the max for,
[maxvalue, maxlocation]=max(yourMatrix(:,2))

Community Treasure Hunt

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

Start Hunting!

Translated by