简体   繁体   English

如何在3D中用给定的点在Matlab中绘图并加入它们?

[英]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? 依此类推,直到大约100,但是我只是获得了很多点的图,如何将它们与线连接起来?

What you're doing right now is telling MATLAB to plot each point separately. 您现在正在做的就是告诉MATLAB分别绘制每个点。 What you should do is to store all your points as a vector and then use plot3 . 您应该做的是将所有点存储为向量,然后使用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 . 还有一种可能是使用称为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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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