-1

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.

Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96
user1641496
  • 457
  • 1
  • 8
  • 18

1 Answers1

6

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))

enter image description here

petrichor
  • 6,459
  • 4
  • 36
  • 48
  • Thanks very much indeed. I may sound stupid here but is there a way of knowing how many holes are within this shape. I mean looking at matlab's example for 2D, the heart shaped points are represented by a diamond shape object after using "convhull". So one could find the proportion of heart cells (nodes) to the total area of the convex hull, or in 3D of the total volume? – user1641496 Nov 06 '12 at 09:57
  • 1
    It is better that you ask this as a separate question. – petrichor Nov 06 '12 at 10:04