1
votes

I have matrix A with size 5x3 which includes 3D (X,Y,Z) coordinates of some points like this:

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 = [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 = [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.

This is how it should look like: desired result

1
I do not understand what you want to plot exactly now that you edited your question. Do you need to visualize the points? should the points be connected? how should the "distance error" be visualized exactly? Maybe you can come up with a 2D example version of what you want the output to look like.m.s.
@m.s. First of al, THX for answer. Second, generally, I want to visualize the distance error between those two points as a line. therefore, the points will not be connected since the distance error is too smaller than the distance between those points, the thing that can be visualized is every related two points with a same color and distance error ( this distance error line is started from first point and its direction is toward second point. I attached a photo in Link.which shows that what I need to visualize I hope you can help meReza_M
I updated my answer, I hope it matches your expectations.m.s.

1 Answers

2
votes

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:

plot