How to find indexes of 10 maximal valuse in a given NxN (symetric) matrix?

1 vue (au cours des 30 derniers jours)
JazzMusic
JazzMusic le 27 Nov 2016
Commenté : JazzMusic le 27 Nov 2016
I have a matrix which state (in each enterence (i,j)) the correlations of the (i,j) pair. I want the indexes of 10 pairs with maximal correlations. Any ideas? My matrix could get big so I am looking for the matlab elegant array/matrix commands (if there is any)
Thanks!

Réponse acceptée

dpb
dpb le 27 Nov 2016
Always just try the straightforward solution first--
nMax=10;
[~,ix]=sort(c(:),1,'descend');
[i,j]=ind2sub(size(c),ix(1:nMax)); % keep top nMax, return locations in array
You can do things like keep values with X% of maximum in array to shrink the population drastically before sorting, etc., if the full-sized array turns out to be too time-consuming, but I'd just go "dead-ahead" until was shown to be a real bottleneck...

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by