I have matrix A
with size 5x3 which includes 3D (X,Y,Z) coordinates of some points like this:
我有一个大小为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:
和矩阵B,大小为5x3,包括其他点的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. Now, My question is how can I plot these two 3D point data sets with their distance error lines in a same plot? 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.
例如,D(1,1)是A(1)和B(1)之间的距离误差,D(2,1)是A(2)和B(2)之间的距离误差,依此类推。现在,我的问题是如何在同一个图中用这些距离误差线绘制这两个3D点数据集?如何以相同的颜色显示每条距离线及其对应的点?例如,来自矩阵A的point1和来自矩阵B的point1以及它们的距离误差用红色显示,然后是来自矩阵A的point2和来自矩阵B的point2,它们的距离误差用蓝色显示,依此类推。
This is how it should look like:
它应该是这样的:
1 个解决方案
#1
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:
#1
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: