Info

This question is closed. Reopen it to edit or answer.

how to find the position of the max componunt

1 view (last 30 days)
Doyoung Kim
Doyoung Kim on 12 Sep 2020
Closed: MATLAB Answer Bot on 20 Aug 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 :(

Answers (1)

Matt J
Matt J on 12 Sep 2020
Edited: Matt J on 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!