Given a vector of real numbers x, find the index idx of n th maximum value. If nth maximum occurs more than once, return the indices of all those occurences.
Example 1:
Input: x = [2 4.5 3 1 3.33], n = 4
Output: idx = 1, since 4th maximum is 2
Example 2: Input: x = [2 4.5 3.33 3 1 3.33], n = 2
Output: idx = [3 6], since 2nd maximum is 3.33
Solution Stats
Problem Comments
1 Comment
Solution Comments
Show comments
Loading...
Problem Recent Solvers79
Suggested Problems
-
Remove any row in which a NaN appears
8783 Solvers
-
Project Euler: Problem 3, Largest prime factor
1809 Solvers
-
Getting the indices from a vector
12211 Solvers
-
07 - Common functions and indexing 4
423 Solvers
-
Element by element multiplication of two vectors
399 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Apologies.Test case 8 is corrected now.