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

조회 수: 1 (최근 30일)
LUI PAUL
LUI PAUL 2015년 3월 31일
댓글: LUI PAUL 2015년 4월 1일
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
  댓글 수: 1
LUI PAUL
LUI PAUL 2015년 4월 1일
thanks Ortino...its working... i have changed the size..will it be ok? A3=(A3)'; B3=(B3)';

댓글을 달려면 로그인하십시오.

추가 답변 (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