Help! How to find mutual numbers in 2 different vectors and replace them with the start and end not in common?

I have this situation 2016 2059 43 2362 2450 88 2450 2474 25 2474 2684 36 3301 3332 31
I would like to find the mutual numbers in the 2 column, replace them and add the number in the column number 3. here is the output that i would like to get
2016 2059 43 2362 2684 149 3301 3332 31

댓글 수: 2

I don't understand. Where are your two vectors? You just give us a list of numbers. The question in the title is not understandable. Could you please tell us more clearly what you want to do?
when i have in start date and in end date mutual value. i want to delete them and get the start value and the last value not in common. and the duration has to b added.Can you help me out?

댓글을 달려면 로그인하십시오.

 채택된 답변

a = [2016 2059 43
2362 2450 88
2450 2474 25
2474 2684 36
3301 3332 31];
b = reshape(a(:,1:2),[],1);
[b1,ii] = histc(b,unique(b));
a1 = reshape(b(ismember(ii,find(b1<2))),[],2);
i1 = zeros(size(a,1),1);
i1(ismember(a(:,1),a1(:,1))) = 1;
out = [a1,accumarray(cumsum(i1),a(:,3))];

댓글 수: 2

BRAVO. it works perfectly. thanks a lot:)
what if the difference between the first column and the second one is 1 and or zero?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2014년 6월 5일

댓글:

2014년 6월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by