Plot a Cuboid with a cylindrical shaped hole in 3D
Show older comments
Hey community,
I would like to plot a shape based on the picture shown below. Most important part is the cuboid in the center with a cylinder hole. It works for the cuboid with 'patch', but i stuck with the cylinder-shaped cutout. Any function recommendation to plot such shape?

Accepted Answer
More Answers (1)
[X,Y,Z]=meshgrid(-150:150);
V=(X.^2+Y.^2>=80^2 & max(abs(X),abs(Y))<=120);
V(:,:,[1,end])=0;
V=V+0.5*imerode(V,ones(3,3,3));
isosurface(X,Y,Z,double(V),1);
2 Comments
Dyuman Joshi
on 30 Oct 2023
Matt J
on 30 Oct 2023
If needed, imerode can be avoided by doing instead,
V=V+0.5*( convn(V, ones(3,3,3),'same') == 27 ) ;
Categories
Find more on Surface and Mesh Plots 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!

