maximal subset N of binary matrix
Mostrar comentarios más antiguos
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 comentario
David
el 16 de En. de 2013
Respuestas (2)
Walter Roberson
el 16 de En. de 2013
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 comentario
David
el 16 de En. de 2013
Andrei Bobrov
el 16 de En. de 2013
M = rand(200) > .95; % your binary matrix
out = M(sum(M,2) > 10,:);
1 comentario
David
el 16 de En. de 2013
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!