Problem 1927. Find nth maximum
Find nth maximum in a vector of integer numbers. Return NaN if no such number exists.
x = [2 6 4 9 -10 3 1 5 -10];
So
- n_max(x,3) would find 3rd maximum value in x which is 5
- n_max(x,8) would find 8th maximum value in x which is -10
- n_max(x,9) would find 9th maximum value in x which is -10
- n_max(x,12) does not exist so return NaN
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
Sky Sartorius
on 10 Oct 2013
The test cases expect isequal(NaN,NaN) to return true. This is wrong.
J.R.! Menzinger
on 10 Oct 2013
please use the function "isquealn" http://www.mathworks.de/de/help/matlab/ref/isequaln.html
Ned Gulley
on 15 Oct 2013
I went ahead and made the test suite change that José suggested above.
Solution Comments
Show commentsGroup

Cody Challenge
- 12 Problems
- 465 Finishers
- Add two numbers
- Find the sum of all the numbers of the input vector
- Quote Doubler
- De-dupe
- Cell joiner
- Remove all the words that end with "ain"
- Nearest Numbers
- Find state names that start with the letter N
- Word Counting and Indexing
- Given two arrays, find the maximum overlap
- It dseon't mettar waht oedrr the lrettes in a wrod are.
- Counting in Finnish
Problem Recent Solvers831
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!