Pair comparison in from other rows
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
raj singh
am 26 Mai 2016
Beantwortet: raj singh
am 29 Mai 2016
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.
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 26 Mai 2016
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,:);
5 Kommentare
Weitere Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!