How to find the fifth largest value in a matrix

3 visualizaciones (últimos 30 días)
Sarah Hicks
Sarah Hicks el 5 de Feb. de 2019
Respondida: Dong Shim el 4 de Mzo. de 2019
Please output the fifth largest number from a two-dimensional matrix with more than 5 elements and no repeated values.
%%Problem 2
disp('PROBELM 2')
disp('Random matrix A')
A=rand(3,3)
B=unique(A)
I am stuck after making the matrix. Any help would be appreciated.

Respuestas (2)

madhan ravi
madhan ravi el 5 de Feb. de 2019
  2 comentarios
Sarah Hicks
Sarah Hicks el 6 de Feb. de 2019
I am still confused on how to find, specifically, the fifth largest number.
madhan ravi
madhan ravi el 6 de Feb. de 2019
when you specify n as 5 the last number in the result is the fifth largest number

Iniciar sesión para comentar.


Dong Shim
Dong Shim el 4 de Mzo. de 2019
B=unique(A);
% 'unique' also sorts A in the ascending order.
disp(B(end-4))

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by