how do i plot control net?

4 visualizaciones (últimos 30 días)
NurFadhilah Samsuddin
NurFadhilah Samsuddin el 14 de En. de 2021
Respondida: Ayush el 19 de Sept. de 2024
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

Respuestas (1)

Ayush
Ayush el 19 de Sept. de 2024
You can plot the control net surrounding the cylinder using "plot3" function itself.
Here's the code for your reference:
% Define the cylinder parameters
outerRadius = 1;
innerRadius = 0.5;
height = 2;
% Define the number of control points in each direction
numPointsX = 10;
numPointsY = 10;
% Generate the control net coordinates
theta = linspace(0, 2*pi, numPointsX);
z = linspace(0, height, numPointsY);
[Theta, Z] = meshgrid(theta, z);
X = outerRadius * cos(Theta);
Y = outerRadius * sin(Theta);
% 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:
You can read more about the "plot3" function here: https://www.mathworks.com/help/matlab/ref/plot3.html
Hope this helps!

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by