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

1 vue (au cours des 30 derniers jours)
LUI PAUL
LUI PAUL le 31 Mar 2015
Commenté : LUI PAUL le 1 Avr 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
  1 commentaire
Ortinomax
Ortinomax le 31 Mar 2015
Please use the button "code", it makes your writing easy to read.

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by