Examining entries in binary matrices and creating new group matrix based on % of connections (defined by 1)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi MATLAB users,
I am a newbie at MATLAB and am trying to run some analyses related to graph theory. I have multiple binary matrices (each 125x125) and would like to create a new 'group' binary matrix based on examining each entry in every matrix and determining if a connection, as defined by '1' in each entry, is present in 75% of all of matrices.
What is the best way I can go about doing this? Any code suggestions would be extremely helpful!
Thanks very much!
0 comentarios
Respuestas (1)
Christine Tobler
el 21 de Mzo. de 2018
If you have each matrix stored in a separate variable, you can do
Atotal = A1 + A2 + A3; % Sum of logical matrices is a numeric matrix
Atotal = (Atotal/3 > 0.75) ; % Create a logical matrix where each entry is true if >75%
% of matrices have an entry that is true
If you have many matrices, it may be easier to store them all in a 3-D array of size 125-by-125-by-numMatrices. Then, the computation you describe can be done like this:
Atotal = sum(A, 3);
Atotal = (Atotal/size(A, 3) > 0.75);
0 comentarios
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!