简体   繁体   English

如何在Matlab中绘制3D分隔线

[英]How to plot 3D separated lines in Matlab

I have matrix A with size 5x3 which includes 3D (X,Y,Z) coordinates of some points like this: 我有A大小为5x3的矩阵A ,其中包括某些点的3D(X,Y,Z)坐标,如下所示:

A = [5.2985 0.3737  6.7050;
     0.5921 2.0948  6.9703;
    -4.2524 3.8338  6.9863;
    -3.9856 3.708   2.7925;
    -3.6727 3.58830 1.2437]

and matrix B with size 5x3 which includes 3D coordinates of another points as well like this: 尺寸为5x3的矩阵B ,其中包括其他点的3D坐标,如下所示:

B = [10.715877  -19.59950    3.575112000;
     14.3055    -17.9177     6.46700;
     17.67064   -16.201099   9.86076800;
     14.8090    -16.30260   12.64600;
     13.412823  -16.49700   13.4652810]

and vector D with size of 5x1 which includes distances error between each points of matrix A and matrix B , like this: 向量D的大小为5x1,其中包括矩阵A和矩阵B每个点之间的距离误差,如下所示:

D = [0.001;
     0.03;
     0.07;
     0.06;
     0.6]

For example D(1,1) is the distance error between A(1) and B(1) and D(2,1) is distance error between A(2) and B(2) and so on. 例如, D(1,1)A(1)B(1)之间的距离误差,而D(2,1)A(2)B(2)之间A(2)距离误差,依此类推。 Now, My question is how can I plot these two 3D point data sets with their distance error lines in a same plot? 现在,我的问题是如何在同一图中绘制这两个3D点数据集及其距离误差线? and how can I show each distance line with its corresponding points in a same color? 怎样用相同的颜色显示每条距离线及其对应的点? for example, point1 from matrix A and point1 from matrix B and their distance error shows with red color, then point2 from matrix A and point2 from matrix B and their distance error show with blue color and so on. 例如, point1从矩阵Apoint1从矩阵B和它们之间的距离误差示出了具有红色,然后point2从矩阵Apoint2从基质B和它们之间的距离误差显示与蓝色等。

This is how it should look like: 它应该是这样的: 理想的结果

I updated my answers to reflect your comments: 我更新了我的答案以反映您的评论:

 hold on;

 BA = B-A;
 cc=hsv(size(A,1));

 for k = 1:size(A,1)
     scatter3([A(k,1),B(k,1)],[A(k,2),B(k,2)],[A(k,3),B(k,3)],'MarkerFaceColor',cc(k,:), 'MarkerEdgeColor', 'none');
     plot3([A(k,1),A(k,1)+BA(k,1)*D(k)],[A(k,2),A(k,2)+BA(k,2)*D(k)],[A(k,3),A(k,3)+BA(k,3)*D(k)],'-', 'Color', cc(k,:));
 end
 hold off;

resulting plot: 结果图:

情节

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

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