简体   繁体   中英

How to 3d plot in matlab with points given, and join them?

I've got few points and I wanted to draw them, and join them with line, I tried:

plot3(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) 

and so on up to about 100, but Im just getting plot with many points, how to join them with line?

What you're doing right now is telling MATLAB to plot each point separately. What you should do is to store all your points as a vector and then use plot3 . Eg,

x=[x1,x2,...,xn];
y=[y1,y2,...,yn];
z=[z1,z2,...,zn];

plot3(x,y,z)

This way you get a line joining your points.

There is another possibility which is using the low level function called line . By taking the above example, your code would look like this:

x=[x1,x2,...,xn];
y=[y1,y2,...,yn];
z=[z1,z2,...,zn];

line(x,y,z);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM