E=[1 2;1 5;2 3;2 4;2 5;3 4;4 5;4 7;4 9;5 6;6 11;6 12;6 13;7 8;7 9;9 10;9 14;10 11;12 13;13 14];N=(1:max(E(:)))'; A=[];for i=1:max(E(:)) if sum(any(ismember(E,N(i)),2),1)==2 A(i)=N(i); endendA(A==0)=[]; %specific number
B={[1,2,5],[2,3,4],[1,2,4,5],[1,2,4,5,6,9,10,11],[1,2,4,5,6,9,13,14]}; % want to see how many times
for i = 1:numel(B) count = 0 ; for j = 1:numel(A) [c,ia] = ismember(B{i}, A(j)) ; if any(c) count = count+1 ; end end number_of_repeat{i} = count ; end
I want have, how many times each elamnet of A is repeated in B
I used above code but does gives me what I want
result should be:
result=[1,4;3,1;10,1;11,0;12,0;14,1]
means that 1 is repeated 4 times. 3 is repeated 1 times.
Best Answer