Pairwise comparison between four vectors
2 次查看(过去 30 天)
显示 更早的评论
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
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
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
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?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!