フィルターのクリア

How can i calculate the distance to all data points?

2 ビュー (過去 30 日間)
Matt
Matt 2012 年 10 月 8 日
I basically want to start at one data point and then calculate the distance to all the other points. Then i want to select the nearest 15. Im not really sure where to start if i'm honest. If someone can point me in the right direction it would be much appreciated

回答 (3 件)

Matt J
Matt J 2012 年 10 月 8 日

Thomas
Thomas 2012 年 10 月 8 日
If you have the statistics toolbox this might help
There is also a file exchange contribution which might help

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 8 日
f1=@(x,y,x0,y0) sqrt((x-x0).^2+(y-y0).^2)
%how to call f1
x=1:100 % example
y=randi(100,1,100)
x0=x(4); y0=y(4) % start point
dist=f1(x,y,x0,y0)
[out,idx]=sort(dist)
res=out(2:16) % 15 first distances
res_idx=idx(2:16) % corresponding index

カテゴリ

Help Center および File ExchangeANOVA についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by