Finding largest values in matrix

8 visualizzazioni (ultimi 30 giorni)
Yaniv
Yaniv il 10 Apr 2016
Commentato: Yaniv il 10 Apr 2016
I would like to find the 10 largest values in a 90x90 matrix, and their indices. Any suggestions? Thanks, Yaniv

Risposta accettata

Ced
Ced il 10 Apr 2016
Modificato: Ced il 10 Apr 2016
A = randn(90);
Nmax = 10; % get Nmax biggest entries
[ Avec, Ind ] = sort(A(:),1,'descend');
max_values = Avec(1:Nmax);
[ ind_row, ind_col ] = ind2sub(size(A),Ind(1:Nmax)); % fetch indices
You can of course also use a while loop and pick out one value at a time.
  1 Commento
Yaniv
Yaniv il 10 Apr 2016
Looks great, exactly what I needed. Thanks.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by