Finding the indices of the maximum k elements (even if repeated)
3 views (last 30 days)
Show older comments
I have an array e.g A=[1 1 0 0 2 0 3 3 0 0] and would like to get the maximum 3 elements (even if repeated ) and their indices
Any help is highly appreciated. Thanks
0 Comments
Accepted Answer
Star Strider
on 15 Jun 2021
One approach —
A=[1 1 0 0 2 0 3 3 0 0];
[Amax,idxmax] = maxk(A,3)
4 Comments
More Answers (0)
See Also
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!