Is this possible?

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.

 采纳的回答

overlaps = a & b;
average_overlap = mean(overlaps(:)); %under one definition

4 个评论

This worked to find the overlap. Now my only issue is that I want to loop this since there are 100 entries in each array (and 6 arrays total). What is the syntax for moving through an array? is there something like a recordset.movenext command?
What do you mean by "move through the array" ? The average_overlap variable I show being calculated is a calculation over the entire array, since that was your question "the average overlap between these matrices". Do you need a row by row calculation? If so then
average_overlap = mean(overlaps,2);
Or do you have cell arrays of matrices? Or 3 dimensional matrices where the third dimension is matrix number? Is pairwise overlap between every one of the 100*99/2 pairs to be calculated?
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.
for J = 1 : length(TheNetworksCellArray)
overlaps = TheNetworksCellArray{J} & ExperimentalMatrix;
average_overlap(K) = mean(overlaps(:));
end

请先登录,再进行评论。

更多回答(1 个)

Timothy
Timothy 2012-5-5

0 个投票

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.

类别

帮助中心File 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