필터 지우기
필터 지우기

Pairwise comparison between four vectors

조회 수: 2 (최근 30일)
nlm
nlm 2018년 10월 17일
댓글: nlm 2018년 10월 22일
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
Jan
Jan 2018년 10월 18일
편집: Jan 2018년 10월 18일
"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?

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

채택된 답변

Jan
Jan 2018년 10월 18일
편집: Jan 2018년 10월 18일
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
Jan
Jan 2018년 10월 19일
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 2018년 10월 22일
No, it worked thanks ! :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by