Given that i have a 4 by N matrix, each entry of the matrix can take a random value from 1-6,
A = randi([1,6],[N 4])
I want to determine how many column(s) of the matrix have 2 distinct pairs of any two numbers from 1-6, for example [1;5;5;1] or [6;6;1;1]
First off, i want to start simply by checking say if the first column of A has 2 '1's and 2 '2's so we want to see if the column is the same as any of { [1;1;2;2;] , [1;2;1;2] , [1;2;2;1] …. }
I think you can do it like this:
valCount = hist( B(:,1) , uniqueVals )'==[2;2;0;0;0;0]
Then i want to generalise this so it can check every possible pairs of values and spit out the number of columns with two distinct pairs of numbers, but i have not a clue how to proceed.
Please if someone could kindly help
Best Answer