Pairwise comparison between four vectors

2 views (last 30 days)
nlm
nlm on 17 Oct 2018
Commented: nlm on 22 Oct 2018
I have 2 pairs of values i.e., 4 vectors, where two vectors within pair have equal length. Vector 1 = [0,1,2,5,6,8], Vector 2=[0,3,4,5,6,7] and Vector 3 =[0,1,2,3,6,8,3,2,4,5,6,8], and Vector 4 =[0,3,4,5,6,7,8,3,5,6,7,8]. Now I want to do pairwise comparison. for example (0,0) and (1,3) in pair 1 is same as (0,0) and (1,3) in pair 2. I have vectors of size 30,000 and 17,000. Any suggestions ?
I tried to use ismember and &&, it doesn't work.
for ii = 1:length(nr1)
if (nr == nr1(ii) || (nc ==nc1(ii)))
k = 1;
end
end
  1 Comment
Jan
Jan on 18 Oct 2018
Edited: Jan on 18 Oct 2018
"It doesn't work" is a weak description of the problem. You do have the information already, so please share it with the readers.
" for example (0,0) and (1,3) in pair 1 is same as (0,0) and (1,3) in pair 2." - what does "is the same" mean exactly? Do only the values matter or even the position in the vectors? What do you want as output?

Sign in to comment.

Accepted Answer

Jan
Jan on 18 Oct 2018
Edited: Jan on 18 Oct 2018
Vector1 = [0,1,2,5,6,8]
Vector2 = [0,3,4,5,6,7]
Vector3 = [0,1,2,3,6,8,3,2,4,5,6,8]
Vector4 = [0,3,4,5,6,7,8,3,5,6,7,8]
A = [Vector1(:), Vector2(:)];
B = [Vector3(:), Vector4(:)];
Result = A(ismember(A, B, 'rows'), :)
Result =
0 0
1 3
2 4
6 6
8 7
  3 Comments
Jan
Jan on 19 Oct 2018
I have no idea what "set of data (nc,nr,IMERGP1)" means. You have mentioned 4 vectors. "nc,nr,IMERGP1" and "nc1, nr1, SMAPP1" sounds like 6 variables. To understand "corresponding IMERGP1 and SMAPP1" it is required to define "corresponding" uniquely.
Does my answer solve the problem or do you need further assistance?
nlm
nlm on 22 Oct 2018
No, it worked thanks ! :)

Sign in to comment.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!