Suppose my
A = [1 2 3; 2 3 1; 2 1 3] % where any digit won't repeat in the same row.
% I need to find out the number of occurrences of each pair.
Expected output:
Pair(1,2) = 1 occurence; Pair(2,1) = 1;Pair(2,3) = 2;Pair(3,2) = 0;Pair(3,1) = 1; Pair(1,3) = 1;
I was trying this code
for n = 2:3 [j,i]=ind2sub(fliplr(size(A)), strfind(reshape(A.',1,[]),[1 n]).'); C = [i,j]; d = numel(C(j)); T9 = table(1, n, d) end
error occurs when the second row ends with 1 and the third row begins with 2.
Best Answer