You could use "polyshape" to create the initial 2D shape. Afterwards, you can use the function "alphaShape" to add the Z dimension and, lastly, you can plot them using a standard "plot3" function.
Please find below a simple example that you might want to use as a starting point to develop your own solution.
% Generate the initial polyshape object p1 = polyshape([0 0 1 1],[1 0 0 1]); p2 = polyshape([0 0 1 1],[1 0 0 1]);
% Extract the vertices of the objects v1 = p1.Vertices; v2 = p2.Vertices;
% Use alphaShape to add the Z dimension a1 = alphaShape( v1(:,1), v1(:,2), 0.1*ones(size(v1,1), 1)); a2 = alphaShape( v2(:,1), v2(:,2), 0.2*ones(size(v2,1), 1));
% Plot the three objects in the same 3D plot plot3(a1.Points(:,1),a1.Points(:,2),a1.Points(:,3),'b') hold on plot3(a2.Points(:,1),a2.Points(:,2),a2.Points(:,3),'r')
Please note that the plots generated with the code above will not be closed as there could not be repeated vertices in the same "alphaShape" object If you want the shape to be closed, a simple way to do it is to add the initial points in the "plot3" instances, such as in the following example:
plot3([a1.Points(:,1); a1.Points(1,1)],[a1.Points(:,2); a1.Points(1,2)],[a1.Points(:,3); a1.Points(1,3)],'b')
