Find nth maximum - MATLAB Cody - MATLAB Central

Problem 1927. Find nth maximum

Difficulty:Rate

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

38.92% Correct | 61.08% Incorrect
Last Solution submitted on May 13, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
3
5
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers840

Suggested Problems

More from this Author2

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page