how do i plot control net?

조회 수: 4 (최근 30일)
NurFadhilah Samsuddin
NurFadhilah Samsuddin 2021년 1월 14일
답변: Ayush 2024년 9월 19일
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

답변 (1개)

Ayush
Ayush 2024년 9월 19일
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!

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by