Matlab code for a rough-surfaced cylinder in 3d

912 Views Asked by At

I am looking to create a rough surfaced hollow cylinder in Matlab. (Think pool noodle stood on end)

Let me first note that I am aware of the cylinder command in Matlab, but do NOT want to use this. This is because I am looking for the equation of such a cylinder as a function Z=f(x,y) for use in another project.

The cylinder should look similar to the image attached, but should also vary in the azimuthal angle to simulate roughness.

Thanks in advance :)

Image of semi-rough cylinder

1

There are 1 best solutions below

0
On

I may have answered my own question here. Here's what I came up with for anybody who is interested.

I used the following code:

[x,y] = meshgrid(-25:0.8:25, -25:0.8:25);
theta=meshgrid(-3*pi:0.3:3*pi);
r = 20 + sin(10.*atan2(y,x))
X = r.*sin(theta);
Y = r.*cos(theta);
Z = cos(50*atan2(y,x)).*sin(100*atan2(y,x)).*exp((atan2(y,x).^2)/1000) +1;
mesh(X,Y,Z);

This created a disgusting mess of a mesh plot, which in this scenario, is exactly what I was after.

If anybody could offer a more visually pleasing way to visualise this plot, I would be deeply grateful.

Rough Cylinder