how do i plot control net?

2 views (last 30 days)
NurFadhilah Samsuddin
NurFadhilah Samsuddin on 14 Jan 2021
Answered: Ayush on 10 Jul 2023
does anyone know how do i plot the control net surrounding the cylinder as shown in the picture above? i tried plot3d but it only appears like the picture attached below

Answers (1)

Ayush
Ayush on 10 Jul 2023
You can plot the control net surrounding the cylinder using plot3 function itself.
% Define cylinder parameters
outerRadius = 1; % Outer radius of the cylinder
innerRadius = 0.5; % Inner radius of the cylinder
height = 2; % Height of the cylinder
% Define number of control points in each direction
numPointsX = 10; % Number of control points along the x-axis
numPointsY = 10; % Number of control points along the y-axis
% Generate the control net coordinates
theta = linspace(0, 2*pi, numPointsX); % Angles along the x-axis
z = linspace(0, height, numPointsY); % Heights along the y-axis
[Theta, Z] = meshgrid(theta, z); % Create meshgrid of angles and heights
X = outerRadius * cos(Theta); % X-coordinates of control points
Y = outerRadius * sin(Theta); % Y-coordinates of control points
% Plot the control net
figure;
plot3(X, Y, Z, 'b.'); % Plot control points
hold on;
mesh(X, Y, Z); % Plot mesh connecting control points
% Draw the outer cylinder
[Xcyl, Ycyl, Zcyl] = cylinder(outerRadius, numPointsX);
Zcyl = Zcyl * height;
surf(Xcyl, Ycyl, Zcyl, 'FaceAlpha', 0.5, 'EdgeColor', 'none', 'FaceColor', 'r');
% Draw the inner cylinder
[Xcyl_inner, Ycyl_inner, Zcyl_inner] = cylinder(innerRadius, numPointsX);
Zcyl_inner = Zcyl_inner * height;
surf(Xcyl_inner, Ycyl_inner, Zcyl_inner, 'FaceAlpha', 0.5, 'EdgeColor', 'none', 'FaceColor', 'g');
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Control Net of Cylinder with Inner Cylinder');
axis equal;
Output:
Hope it helps.

Categories

Find more on 2-D and 3-D 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!