how to know the indices of multiple max values?

46 Ansichten (letzte 30 Tage)
Jaybee
Jaybee am 1 Okt. 2013
hi there!
I'm having problem about identifying the indices(position) of a multiple max values.
example of input:
A=[4 5 9 9]
how can i know the indices of those 9's?

Akzeptierte Antwort

Wayne King
Wayne King am 1 Okt. 2013
Bearbeitet: Wayne King am 1 Okt. 2013
One way:
A = [4 5 9 9];
maxval = max(A);
lia = ismember(A,maxval);
idx = find(lia);
or shorter
maxval = max(A);
idx = find(A == maxval);
  2 Kommentare
Jaybee
Jaybee am 1 Okt. 2013
thank you so much bro :)
vimal kumar chawda
vimal kumar chawda am 9 Jul. 2021
what if we have matrix?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by