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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!