How to find indexes of 10 maximal valuse in a given NxN (symetric) matrix?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
dpb
2016 年 11 月 27 日
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...
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!