I have a simulation code that creates a binary matrix in matlab always with 10 rows, but with a different number of columns.
For instance:
1 0 0 0
0 0 0 0
0 1 0 0
1 0 0 0
1 0 0 0
1 0 1 0
0 0 0 1
1 0 0 0
0 0 0 0
0 0 0 0
I want to do a pairwise comparison between the lines to determine how many elements differ between the two lines, eventually create a 10x10 symmetric matrix with the number of differences between the lines. For instance. Line 1 compared to line 2 ... and so on.
Thus, the element (1,2) (and also the element 2,1) of this matrix will compare row 1 with row 2 and in this case will be 1, since there is only one difference.
I know this can be done with a lot of coding of the loop, however, there seems to be a simpler way that I don't know about.
How should this be achieved?