Filter löschen
Filter löschen

Pairwise comparison between four vectors

2 Ansichten (letzte 30 Tage)
nlm
nlm am 17 Okt. 2018
Kommentiert: nlm am 22 Okt. 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 Kommentar
Jan
Jan am 18 Okt. 2018
Bearbeitet: Jan am 18 Okt. 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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 18 Okt. 2018
Bearbeitet: Jan am 18 Okt. 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 Kommentare
Jan
Jan am 19 Okt. 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 am 22 Okt. 2018
No, it worked thanks ! :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by