Problem 1991. Find the index of nth maximum of a row vector of real numbers
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
Apologies.Test case 8 is corrected now.
Solution Comments
Show commentsProblem Recent Solvers52
Suggested Problems
-
Find the largest value in the 3D matrix
1574 Solvers
-
Determine the number of odd integers in a vector
765 Solvers
-
Create an n-by-n null matrix and fill with ones certain positions
648 Solvers
-
Relative ratio of "1" in binary number
1498 Solvers
-
Back to basics - mean of corner elements of a matrix
436 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!