Examining entries in binary matrices and creating new group matrix based on % of connections (defined by 1)

1 次查看(过去 30 天)
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!

回答(1 个)

Christine Tobler
Christine Tobler 2018-3-21
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);

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by