Clear Filters
Clear Filters

How to create nodal model of cylinder in matlab ?

8 views (last 30 days)
generate evenly spaced points along the height and circumference.

Answers (1)

Aditya Singh
Aditya Singh on 12 Jul 2023
Hi Sakshi,
To my understanding you want to create a nodal model of cyclinder.
You can use the meshgrid function to generate a grid of points in the x-y plane and then stack them along the z-axis to form the cylinder. See the below code for reference.
% Parameters
radius = 1; % Radius of the cylinder
height = 2; % Height of the cylinder
numCircumNodes = 20; % Number of nodes along the circumference
numHeightNodes = 10; % Number of nodes along the height
% Generate nodal coordinates
theta = linspace(0, 2*pi, numCircumNodes+1);
z = linspace(0, height, numHeightNodes);
[Theta, Z] = meshgrid(theta, z);
X = radius * cos(Theta);
Y = radius * sin(Theta);
% Reshape the coordinates into column vectors
X = X(:);
Y = Y(:);
Z = Z(:);
% Plot the nodal coordinates
scatter3(X, Y, Z, 'filled');
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Nodal Model of a Cylinder');
axis equal;
For more information you can refer to
Hope it helps!

Community Treasure Hunt

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

Start Hunting!