Find approximate match between 2 matrices.

2 次查看(过去 30 天)
Hi all,
I have 2 matrices of 10000 x 3 and 15000 x 3 of floating numbers. where in for example
A=[x1,y1,z1] and B=[x2,y2,z2]
A=[22.35 55.36 110.72 & B=[12.65 15.36 22.36
21.48 -54.35 -35.65 22.35 54.36 113.36
32.64 65.35 -110.35 15.36 175.23 23.65
23.35 54.36 112 6.56 18.56 -72.36
6.35 -90.35 -156.36 7.35 -92.32 -153.72
19.36 -12.36 176.53 18.72 -10.36 176.78
22.36 15.36 22.36] 23.36 17.36 19.88]
I want to approximate match x1 to x2,y1 to y2, and z1 to z2 with tolerance of +/- 1.0000 for x, +/- 2.0000 for y and +/- 3.000 for z matching. If I find approximate match, I want to make a separate matrix of of A1 and B1.
A1=[x11,y11,z11] and B1=[x21,y21,z21]
A1=[23.35 55.36 110.72 & B1=[22.35 54.36 113.36
22.35 54.36 112 22.35 54.36 113.36
6.35 -90.35 -156.36 7.35 -92.32 -153.72
19.36 -12.36 176.53 18.72 -10.36 176.78
22.36 15.36 22.36] 23.36 17.36 19.88]
Where A1 is the values of A coinciding with B and B1 is the coinciding values of A with B. Such that size of A1 and B1 are same.
  1 个评论
Rik
Rik 2017-10-31
What have you tried? Do you have a small example you could show input and output for? Have a read here and here. It will greatly improve your chances of getting an answer.

请先登录,再进行评论。

采纳的回答

Rik
Rik 2017-11-2
编辑:Rik 2017-11-2
You can try pdist2 with a custom distance function: a function that returns only true or false. Your custom function needs to return a numeric array, and logical apparently doesn't count. 15k by 15k might not fit in memory (1 800 000 000 bytes=225MB for double, 1/8 for logical, uint8 or int8).
DISTFUN=@(ZI,ZJ) uint8(...
abs(ZJ(:,1)-ZI(1))<=1 ...
& abs(ZJ(:,2)-ZI(2))<=2 ...
& abs(ZJ(:,3)-ZI(3))<=3);
within_tolerance=pdist2(A,B,DISTFUN);
With that matrix you can generate A1 and B1 with the sort you need.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by