Draw a 3D model having x,y and z coordinates

Hello everyone i would like to know if you can help me with this question. I have an (6000x3) array, where the columns represents x,y and z coordinates of a point that when u link all of the points , they form a cylinder.
Is posible to create the model with those coordinates?

 Accepted Answer

Your coordinates given are not forming a full cylinder. If you join them, you will not get a perfect cylinder as expected. As you said the points form a cyinder; I used the points to get radius and height of the cylinder, from this cylinder has been plotted.
data = xlsread("coordinates.xlsx") ;
x = data(:,1) ;
y = data(:,2) ;
z = data(:,3) ;
% Get radius of the Cylinder
Radius = mean(sqrt(x.^2+y.^2)) ;
% Center of cylinder
C = [0. 0.] ;
% Get height of the cylinder
Height = max(z) ;
% form cylinder
theta = 360. ; % Angle of the Cylinder
%
NH = 50 ; % Number of Elements on the Height
NT = 50 ; % Number of Angular Dicretisation
% Discretizing the Height and Angle of the cylinder
nH = linspace(0,Height,NH) ;
nT = linspace(0,theta,NT)*pi/180 ;
[H T] = meshgrid(nH,nT) ;
% Convert grid to cylindrical coordintes
X = Radius*cos(T);
Y = Radius*sin(T);
Z = H ;
surf(X,Y,Z)
hold on
plot3(x,y,z,'.k')

1 Comment

Wow, thank you very much KSSV, this really helps me. Now that i can see those points in the cylinder, will help a lot.
Again, thanks. Regards.

Sign in to comment.

More Answers (0)

Categories

Find more on Aerospace Blockset in Help Center and File Exchange

Products

Tags

Community Treasure Hunt

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

Start Hunting!