필터 지우기
필터 지우기

Common pairs from all rows except first row (vector) and how many times....

조회 수: 3 (최근 30일)
A1=[1 4];
A2=[1 3 4];
A3=[1 2 3 4];
A4=[1 2 6 3 4];
I want common pairs from all row (vectors) except first row. It means my answer will be (3 4) and (1 2). May this is possible to print like this:
(Total no of row).........(Pair)............(How many times)
4 (3 4) 3
4 (1 2) 2

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 5월 29일
편집: Andrei Bobrov 2016년 5월 29일
A = {A1,A2,A3,A4};
C = cellfun(@(x) hankel(x(1:end-1),x(end-1:end)),A,'un',0);
[a,~,c] = unique(cat(1,C{:}),'rows');
ii = histc(c,1:size(a,1));
t = ii > 1;
out = [a(t,:), ii(t)]
sprintf('(%d %d) %d',out')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by