MATLAB Answers

0

How to extract two equal maximum values at different index

Asked by Khang Nguyen on 20 Mar 2019
Latest activity Answered by KSSV
on 20 Mar 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.

  0 Comments

Sign in to comment.

Products


Release

R2018b

2 Answers

Answer by Birdman
on 20 Mar 2019
Edited by Birdman
on 20 Mar 2019
 Accepted Answer

index=find(A==max(A))
This should give you the indexes.

  0 Comments

Sign in to comment.


Answer by KSSV
on 20 Mar 2019

A = [8,5,6,7,8]
maxval = max(A);
lia = ismember(A,maxval);
idx = find(lia);

  0 Comments

Sign in to comment.