开发者

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

开发者 https://www.devze.com 2023-02-22 17:37 出处:网络
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, x开发者_开发问答3, y3, z3, x4, y4, z4)

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, x开发者_开发问答3, 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. E.g.,

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号