How to extract two equal maximum values at different index

1 visualización (últimos 30 días)
Khang Nguyen
Khang Nguyen el 20 de Mzo. de 2019
Respondida: KSSV el 20 de Mzo. de 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.

Respuesta aceptada

Birdman
Birdman el 20 de Mzo. de 2019
Editada: Birdman el 20 de Mzo. de 2019
index=find(A==max(A))
This should give you the indexes.

Más respuestas (1)

KSSV
KSSV el 20 de Mzo. de 2019
A = [8,5,6,7,8]
maxval = max(A);
lia = ismember(A,maxval);
idx = find(lia);

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by