how do i plot control net?

7 vues (au cours des 30 derniers jours)
NurFadhilah Samsuddin
NurFadhilah Samsuddin le 14 Jan 2021
Réponse apportée : Ayush le 19 Sep 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

Réponses (1)

Ayush
Ayush le 19 Sep 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!

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by