Vercat Issue with 3D plot

1 view (last 30 days)
Minas Emiris
Minas Emiris on 21 Apr 2018
Edited: Walter Roberson on 21 Apr 2018
I am generating a code for two cylinders, and even though I manage to plot them on 3d as desired by the use of hold on's, when attempting to generate a large matrix summarising both cylinders, I get a surface connecting the two shapes that I have not defined anywhere. My code is:
[x,y,z] = cylinder(50,500);
hold on
[x1,y1,z1] = cylinder(45,500);
z1 = z1* 10;
hold on
[x2,y2,z2] = cylinder([45 50],500);
z2(1,:) = 10;
z2(2,:) = 10;
hold on
[x3,y3,z3] = cylinder([45 50],500);
z3(1,:) = 0;
z3(2,:) = 0;
hold on
[x4,y4,z4] = cylinder(20,500);
z4 = z4*10;
hold on
[x5,y5,z5] = cylinder(25,500);
z5 = z5*10;
hold on
[x6,y6,z6] = cylinder([20 25],500);
z6(1,:) = 0;
z6(2,:) = 0;
hold on
[x7,y7,z7] = cylinder([20 25],500);
z7(1,:) = 10;
z7(2,:) = 10;
hold on
x = vertcat(x1,x2,x3,x4,x5,x6,x7);
y = vertcat(y1,y2,y3,y4,y5,y6,y7);
z = vertcat(z1,z2,z3,z4,z5,z6,z7);
I want to get rid of the surface which matches the two cylinders. You will be able to see the shape I want if you delete the last three lines of the code.

Answers (0)


Find more on Triangulation Representation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!