Borrar filtros
Borrar filtros

How to find second largest OR third largest Or any largest value among the columns of a matrix?

15 visualizaciones (últimos 30 días)
I have a matrix A=rand(7,25)
I want to find the second largest/third largest/fourth/fifth and sixth largest value among all the columns of matrix "A". No need of seventh largest as there are total 7 values in each column.
Thank you.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 7 de Oct. de 2014
Editada: Azzi Abdelmalek el 7 de Oct. de 2014
A=rand(7,25)
[aa,indices]=sort(A,'descend')
  4 comentarios
Image Analyst
Image Analyst el 7 de Oct. de 2014
They're all in indices. Why do you need different arrays??? If you do, just do
maxIndexes = indices(1,:);
max2Indexes = indices(2,:);
max3Indexes = indices(3,:);
and so on.
Kasun Kariyawasam
Kasun Kariyawasam el 16 de Nov. de 2018
Thanks very much. This is a good one - it gives correct indices of the original array for any max

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by