MATLAB: How to know the indices of multiple max values

arrayindicesMATLABmultiple max

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?

Best Answer

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);