basic question on how to find mean distance between an interior point and all of the vertex points of the convex hull

1 次查看(过去 30 天)
Hi,
I know how to get the convex hull of a set of 3 dimensional points:
% Create the data.
n = 50;
X = randn(n,3);
% Plot the points.
plot3(X(:,1),X(:,2),X(:,3),'ko','markerfacecolor','k');
% Compute the convex hull.
C = convhulln(X);
I have certain interior base locations and I want to determine the average (mean) distance between the base location and all other points on the vertex of the convex hull. How do I do this easily? Thank you for your time
Andrew

回答(1 个)

Laurens Bakker
Laurens Bakker 2012-3-7
Hi Andrew,
If you have the Statistics toolbox, use the pdist function to compute the distance between a vector of points and a single point. Otherwise, do it by hand:
P = unique( C, 'rows' );
dist = sqrt(sum( bsxfun(@minus,P,yourBaseLocation) .^ 2, 2 ));
I used Euclidean distance: sqrt(sum( (A - B)^2 ))
Cheers,
Laurens

类别

Help CenterFile Exchange 中查找有关 Bounding Regions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by