MATLAB: How to calculate if two matrices have similar elements.

comparing rowsmatix comparison

I've got a number of different csv files which have the following format;
Number, Number, Number, Number, Number, Text.
Below are some examples.
3764.92,3764.92,-759.167,58.8299,65.4035,1,One
165.493,3234.51,-1940.46,311.928,63.8692,1,Three
I was wondering if its at all possible to calculate if 2 different matrices have similar elements (the same rows) and how many of the same elements they have. There are 34 columns per file.
Any help would be much appreciated!

Best Answer

  • total=0;
    for num=1:34
    if isequal(file1(num),file2(num))
    total=total+1;
    end
    end
    sum will return the number of same elements