Reputation: 1
I have the text file of point cloud data, for example
[17.42851 7.370431 -0.8465996
17.3368 7.309645 -0.6999135
17.17311 7.201123 -0.4422026
17.26928 7.269999 -0.5591076
17.09828 7.153707 -0.3068624
17.59379 7.476501 -0.8979237]
In above .txt file in first row first value indicates x coordinate, 2nd indicates y and 3rd indicates z coordinate.
By using uiimport
command in matlab , I imported it but the problem is, I want to plot these points layer by layer, so how should I separate it layer by layer? Please tell me the command from matlab.
Upvotes: 0
Views: 2234
Reputation: 25232
your matrix:
A = [17.42851 7.370431 -0.8465996;
17.3368 7.309645 -0.6999135;
17.17311 7.201123 -0.4422026;
17.26928 7.269999 -0.5591076;
17.09828 7.153707 -0.3068624;
17.59379 7.476501 -0.8979237];
has the length:
L = size(A,1);
First you need to replicate it:
B = repmat(A,L,1);
and then sort the last row (z):
B(:,3) = sort(B(:,3))
which results in:
17.4285 7.3704 -0.8979
17.3368 7.3096 -0.8979
17.1731 7.2011 -0.8979
17.2693 7.2700 -0.8979
17.0983 7.1537 -0.8979
17.5938 7.4765 -0.8979
...
17.4285 7.3704 -0.3069
17.3368 7.3096 -0.3069
17.1731 7.2011 -0.3069
17.2693 7.2700 -0.3069
17.0983 7.1537 -0.3069
17.5938 7.4765 -0.3069
which you then could plot with
scatter3(B(:,1),B(:,2),B(:,3));
leading to:
Upvotes: 2
Reputation: 270
If I've understood correctly, you want to plot each plane.
scatter(x,y,2,z)
will plot a 2D plot of x and y coordinates with points of size 2. The colours of the plot will be the linear mapping of the z coordinates.
You can proceed in the same fashion for the other planes...
scatter(x,z,2,y)
will plot the xz plane
Alternatively you could just plot the 3D pointcloud using
scatter3(x,y,z)
then click on the rotate button in the MATLAB figure and right click on the figure to change the view (to xy, xz,yz plane)
Upvotes: 0