How to extract two equal maximum values at different index

1 次查看(过去 30 天)
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.

采纳的回答

Birdman
Birdman 2019-3-20
编辑:Birdman 2019-3-20
index=find(A==max(A))
This should give you the indexes.

更多回答(1 个)

KSSV
KSSV 2019-3-20
A = [8,5,6,7,8]
maxval = max(A);
lia = ismember(A,maxval);
idx = find(lia);

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by