maximal subset N of binary matrix

조회 수: 2 (최근 30일)
David
David 2013년 1월 16일
Hello, i have a 200x200 symmetric binary matrix that's relatively sparse. I want to choose a subset N of rows with their matching columns that have the largest sum (i.e. most 1's).
That is, imagine it's set of 200 subjects, and I've got a matrix of all their interactions (that are either successful =1, or failures = 0). I want to find, for example, the 10 subjects that were the most successful (doesn't matter if there are more than one subset of 10 that did perfectly, I just need to find one)
I'm racking my brain trying to do this efficiently and hope someone might have a good solution out there.
thank you very much for your time, dave
  댓글 수: 1
David
David 2013년 1월 16일
Thank you for your responses, I think I wasn't very clear!
I need not the 10 largest row (col) sum, but need the 10 subjects whose interactions were the greatest. Say, for example, I just wanted the top 3 performers, and looked at subject 4 7 11. I would look at their matching coordinates and sum that value as their total score (which, in this case, would include 6 matrix element values, the 6 interactions for the three subjects).
So i'm not really looking for the max columns, but the max interactions for a given subset of N subjects within a larger set of say, 200 subjects. I hope that is more clear. thank you for the fast responses!

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2013년 1월 16일
That array is not very big, so I would suggest something like
[maxvals, maxidx] = sort( sum(YourArray), 'descend' )
then maxvals(1:10) are the values and maxidx(1:10) are the corresponding row indices, and YourArray(maxidx,:) would be the rows.
  댓글 수: 1
David
David 2013년 1월 16일
see my comments above, thank you for your responses.

댓글을 달려면 로그인하십시오.


Andrei Bobrov
Andrei Bobrov 2013년 1월 16일
M = rand(200) > .95; % your binary matrix
out = M(sum(M,2) > 10,:);
  댓글 수: 1
David
David 2013년 1월 16일
see my comments above, thank you for your responses.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by