Is this possible?

1 view (last 30 days)
Timothy
Timothy on 4 May 2012
I wanted to make sure that this was possible to do in MATLAB and possibly how I would do it.
I have an array of 100 random binary, undirected matrices that I've calculated. I need to find the average overlap between these matrices. I know how to do this conceptually but not in code: add two matrices, where there is a 2, there is an overlap, do this for all comparisons and average.
However, I have no idea how to do this in code or if it's even possible.

Accepted Answer

Walter Roberson
Walter Roberson on 4 May 2012
overlaps = a & b;
average_overlap = mean(overlaps(:)); %under one definition
  4 Comments
Timothy
Timothy on 5 May 2012
It is a cell array of matrices. This is what I want to do:
One cell array of matrices (random networks)
One "experimental" matrix
I need to compare the experimental matrix to each of the matrices in the random networks cell array for overlap. I need to count how many overlaps there are in each comparison and then average these. I have no idea how to do this as I only know VBA and this is my first time using MATLAB.
Walter Roberson
Walter Roberson on 5 May 2012
for J = 1 : length(TheNetworksCellArray)
overlaps = TheNetworksCellArray{J} & ExperimentalMatrix;
average_overlap(K) = mean(overlaps(:));
end

Sign in to comment.

More Answers (1)

Timothy
Timothy on 5 May 2012
i mentioned this in the comments but is there a way to loop through these comparisons instead of doing it by hand? I have one matrix that I need to compare for overlap to 100 random matrices currently in a cell array. If possible, I'd also like to have the loop count the number of overlaps in each(this is the only important number I need) comparison.
i've tried a few things like for a = cellarray{1,1:1,100} but these obviously haven't worked so far.

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!