Convhull in Matlab

折月煮酒 提交于 2020-01-17 15:27:11

问题


I have 3 vectors of position data : x, y and z

x = [0.1524 0.1219 0.0610 0.0914 0.0610 0.1219 0.0305 0.0914 0.2134 0.0610 0.1219
0.0305 0.0610 0.1219 0.0914 0.1524 0.0610 0.1524 0.0610 0.0610 0.0610 0.0610
0.1524 0.0914 0.0610 0.1524 0.0610 0.2134 0.0610 0.0914 0.1524];

y = [0.1219 0.1524 0.0305 0.1219 0.1524 0.1524 0.0610 0.1219 0.1219 0.1524 0.1524
0.0610 0.0914 0.1524 0.1829 0.1829 0.0914 0.1829 0.2134 0.0914 0.2134 0.0914
0.1829 0.0610 0.0914 0.1829 0.0914 0.1829 0.2134 0.1219 0.1829];

z = [0.0305 0.0305 0.0610 0.0610 0.0610 0.0610 0.0914 0.0914 0.0914 0.0914 0.0914
0.1219 0.1219 0.1219 0.1219 0.1219 0.1524 0.1524 0.1524 0.1829 0.1829 0.2134
0.2134 0.2438 0.2438 0.2438 0.2743 0.2743 0.2743 0.3048 0.3048];

I was wondering how I could apply convex-hull on this set? Matlab doesn't accept this format but regularly spaced grid.


回答1:


You can use convhulln to compute the convex hull for dimensions grater than 2. If you want to plot the results, use trisurf. See the sample code for your input below:

X = [x;y;z]'; %# involves a 3D point on each row  
K = convhulln(X);
trisurf(K,X(:,1),X(:,2),X(:,3))



来源:https://stackoverflow.com/questions/13247475/convhull-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!