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
  1 件のコメント
Ortinomax
Ortinomax 2015 年 3 月 31 日
Please use the button "code", it makes your writing easy to read.

サインインしてコメントする。

採用された回答

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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by