The convex hull of a data set in n-dimensional space

The convex hull of a data set in n-dimensional space 

>> figure, hold on
d = [1 2 3 1]; % Index into C column.
for i = 1:size(C,1) % Draw each triangle.
j= C(i,d); % Get the ith C to make a patch.
 h(i)=patch(X(j,1),X(j,2),X(j,3),i,'FaceAlpha',0.9);
end % 'FaceAlpha' is used to make it transparent.
hold off
view(3), axis equal, axis off
camorbit(90,-5); % To view it from another angle
title('Convex hull of a cube')
Undefined function or variable 'C'.

>> d = [-1 1];
[x,y,z] = meshgrid(d,d,d);
X = [x(:),y(:),z(:)]; % 8 corner points of a cube
C = convhulln(X)

C =

     4     2     1
     3     4     1
     7     3     1
     5     7     1
     7     4     3
     4     7     8
     2     6     1
     6     5     1
     4     6     2
     6     4     8
     6     7     5
     7     6     8

>>  figure, hold on
d = [1 2 3 1]; % Index into C column.
for i = 1:size(C,1) % Draw each triangle.
j= C(i,d); % Get the ith C to make a patch.
 h(i)=patch(X(j,1),X(j,2),X(j,3),i,'FaceAlpha',0.9);
end % 'FaceAlpha' is used to make it transparent.
hold off
view(3), axis equal, axis off
camorbit(90,-5); % To view it from another angle
title('Convex hull of a cube'

Post a Comment

0 Comments