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

5 Ansichten (letzte 30 Tage)
Borja Zamarreño
Borja Zamarreño am 6 Jun. 2020
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?

Akzeptierte Antwort

KSSV
KSSV am 6 Jun. 2020
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 Kommentar
Borja Zamarreño
Borja Zamarreño am 6 Jun. 2020
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by