Given a vector v = [2 2]
I am trying to find how many times it is present in a matrix, say
data_2 =
2 2
2 2
1 2
2 2
2 1
1 2
2 1
1 1
2 2
2 2
In the above dummy example, [2 2]
occurs in 5 rows out of total 10 rows present. The following code should ideally be giving me the same answer -
numel(find(data_2 == repmat(v,size(data_2,1),1)))
However the answer for the above is 14. Logically I am trying to simply count occurrences, but I must have messed up with the MATLAB commands. Any help would be appreciated.