How to extract two equal maximum values at different index

1 Ansicht (letzte 30 Tage)
Khang Nguyen
Khang Nguyen am 20 Mär. 2019
Beantwortet: KSSV am 20 Mär. 2019
Hi guys,
How can I point out the different location of two maximum values
example A = [8,5,6,7,8]
If i type [max_A, index] = max(A), it will give me max = 8 and index = 1, but in this case the index must be 1 and 5.

Akzeptierte Antwort

Birdman
Birdman am 20 Mär. 2019
Bearbeitet: Birdman am 20 Mär. 2019
index=find(A==max(A))
This should give you the indexes.

Weitere Antworten (1)

KSSV
KSSV am 20 Mär. 2019
A = [8,5,6,7,8]
maxval = max(A);
lia = ismember(A,maxval);
idx = find(lia);

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by