MATLAB: Pair comparison in from other rows

combinationcomparisonmatrixpair

I have:
A1=[3 4]
A2=[3 1 4]
A3=[3 2 1 4]
want to convert as:
(3,4)
(3,1)(1,4)
(3,2)(2,1)(1,4)
Now I want to check, is any pair common in all rows (except first rows)
For example: combination (1,4) is common in 2 and 3 row. In the result, I want this pair. Please help me to complete this program.

Best Answer

A = {A1,A2,A3};
C = cellfun(@(x) hankel(x(1:end-1),x(end-1:end)),A,'un',0);
[a,~,c] = unique(cat(1,C{:}),'rows');
out = a(histc(c,1:size(a,1)) > 1,:);