Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Problem 1927. Find nth maximum

Created by Awadhesh Srivastava

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];


  • 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

Problem Group

Solution Statistics

65 correct solutions 55 incorrect solutions
Last solution submitted on Oct 05, 2015

Problem Comments

Solution Comments