poster
2019-12-10, 20:41
我有一组数据点,每个数据点都属于某个群集(组)。我需要在每个群集周围绘制一个多边形。有谁知道该怎么做?
我是否使用实际的数据点绘制多边形都没有关系。我只需要将它们包裹在多边形中即可。
回答:
尝试使用convhull (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/convhull.html)函数。它从数据集中定义凸包的点返回索引。您必须对绘制的每个群集执行此操作。
例如:
x=rand(1,100); %#generate x and y data for your clusters y=rand(1,100); k=convhull(x,y); %#generate indices marking the outermost points hold on plot(x,y,'b.') %# plot your cluster points plot(x(k),y(k),'r-') %# plots only k indices, giving the convex hull 这将为您提供一个多边形,其索引与聚类的离群值重合。
更多&回答... (https://stackoverflow.com/questions/2814336)
我是否使用实际的数据点绘制多边形都没有关系。我只需要将它们包裹在多边形中即可。
回答:
尝试使用convhull (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/convhull.html)函数。它从数据集中定义凸包的点返回索引。您必须对绘制的每个群集执行此操作。
例如:
x=rand(1,100); %#generate x and y data for your clusters y=rand(1,100); k=convhull(x,y); %#generate indices marking the outermost points hold on plot(x,y,'b.') %# plot your cluster points plot(x(k),y(k),'r-') %# plots only k indices, giving the convex hull 这将为您提供一个多边形,其索引与聚类的离群值重合。
更多&回答... (https://stackoverflow.com/questions/2814336)