How to find indexes of 10 maximal valuse in a given NxN (symetric) matrix?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
JazzMusic
am 27 Nov. 2016
Kommentiert: JazzMusic
am 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!
0 Kommentare
Akzeptierte Antwort
dpb
am 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...
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!