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

1 view (last 30 days)
LUI PAUL on 31 Mar 2015
Commented: LUI PAUL on 1 Apr 2015
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 on 31 Mar 2015

Ortinomax on 31 Mar 2015
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
LUI PAUL on 1 Apr 2015
thanks Ortino...its working... i have changed the size..will it be ok? A3=(A3)'; B3=(B3)';

### Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by