MATLAB: Is this possible

overlap

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.

Best Answer

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