how to find nearest distant points for two unequal sized pair of data

1 次查看(过去 30 天)
I have two set of points set1>>{A1(6840*1),B1(6840*1)} and set2>>{A2(10227*1),B2(10227*1)}. I want to find the nearest distant points(<=0.05) taking one set fixed. I have tried like this
for i=1:length(A2); difference1=A1-A2(i); difference2=B1-B2(i); P=sqrt((difference1.^2)+(difference2.^2))<=0.05; end A3=A2(P); B3=B2(P); so the nearest points w.r.t set (A1,B1) is (A3,B3) but this result is not matching with manual result.please help

采纳的回答

Ortinomax
Ortinomax 2015-3-31
When you do
A3=A2(P); B3=B2(P);
P is a "boolean", it is either at 0 or 1 depending of the inequality. I tried this, and it seems to work. For each poitn of [A1;B1], it gives the nearest [A2;B2] points (and C3 indicates i we respect the proximity limit).
C3=0*A1;
for k=1:length(A1);
C=A2-A1(k)+1i*(B2-B1(k))
[minD ind]=min(abs(C))
A3(k)=A2(ind);
B3(k)=B2(ind);
C3(k)=minD<=0.05
end

更多回答(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