MATLAB: Create soild oblique cylinders and upright cylinder mesh in different positions

oblique cylinder

hi how to create three oblique cylinders and upright cylinder mesh in same figure the three upright/oblique cylinders in different positions and one of them has different degree with( intersect) other cylinder ths u ex the oblique cylinder cross x axia 45 degree
R =0.2 ; % Radius of the cylindrical shell
H =3 ; % Height of the Cylinder
M = 1000 ;N = 1000 ;
x=[];y=[];z=[];dz=0;
% Discretizing the Height and Angle of the cylinder
nH = linspace(0,H,M) ;
nT = linspace(0,2*pi,N) ;
[H, T] = meshgrid(nH,nT) ;
%%cylinder at (0,0)
X1 = R*cos(T);
Y1 = R*sin(T);
Z1 = --2.36*sind(R)
surf(X1,Y1,Z1)

Best Answer

axes('NextPlot', 'add');
[X,Y,Z] = cylinder(r,n);
Now modify X,Y,Z as wanted, e.g.:
surf(X,Y,Z);
surf(X + 10,Y,Z);
surf(X + 20,Y,Z);
For the rotation apply a rotation matrix.