# Pairwise comparison between four vectors

3 vues (au cours des 30 derniers jours)
nlm le 17 Oct 2018
Commenté : nlm le 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 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Jan le 18 Oct 2018
Modifié(e) : Jan le 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?

Connectez-vous pour commenter.

### Réponse acceptée

Jan le 18 Oct 2018
Modifié(e) : Jan le 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 commentairesAfficher 1 commentaire plus ancienMasquer 1 commentaire plus ancien
Jan le 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 le 22 Oct 2018
No, it worked thanks ! :)

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by