フィルターのクリア

How to find the median distance between points within an alpha shape?

7 ビュー (過去 30 日間)
Bin Qi
Bin Qi 2021 年 2 月 20 日
編集済み: Gaurav Garg 2021 年 2 月 26 日
I want to know the median and average distance between the points within the created alpha shape. How can I do that?
I can use pdist([x,y]) to find all posible distances and remove the values larger than the alpha, then find the median but I think it is very ineficient.

採用された回答

Gaurav Garg
Gaurav Garg 2021 年 2 月 26 日
編集済み: Gaurav Garg 2021 年 2 月 26 日
Hi Bin,
You can find distance between a query point and multiple other points in the following 2 ways -
tic;d = x-Y
a = abs(d(:,1))+abs(d(:,2));toc
tic;
for i=1:242
for j=1:2
d(i,j) = x(i,j) - Y(j)
end
b(i) = abs(d(i,1)) + abs(d(i,2))
end
toc;
Here, x is the array of 2-D points and Y is the 1-by-2 query point and you have 242 points in x.
Also, you would observe that the first way is almost 50x more efficient than the second way. This is because the first way uses vectorization, unline the second way which uses loops.
You can then apply median function to find median, or compare each distance with alpha. Note that this can also be done through vectorization.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by