Want to connect 3D scattered data points with line
5 ビュー (過去 30 日間)
古いコメントを表示
Hello guys,
I am trying to do a 3D scattered data plot and I want to conncet the points from the data with a line, I was able to do it but I am not sattisfied with the result. I dont want to connect the,m one after another, I want to connect point one with point two, then point one with point three and so on, I will insert a picture to make maybe more clear. And also I want to see the distance between two points, how its possible to do this?
Here is the code what I am using:
x = [264 260 293 241 280 259]
y = [264 335 333 318 310 349]; %%I am using the pixel value for Y each point
z = [70 21 27 9 1 53]; %I am using the pixel value for Z each point
figure
axis equal
scatter3(x,y,z, 'filled')
text (x(1),y(1),z(1),'Rot. Point');
text (x(2),y(2),z(2),'Center');
text (x(3),y(3),z(3),'Left');
text (x(4),y(4),z(4),'Right');
text (x(5),y(5),z(5),'Down');
text (x(6),y(6),z(6),'Up');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/530769/image.png)
.
0 件のコメント
回答 (1 件)
J. Alex Lee
2021 年 2 月 25 日
編集済み: J. Alex Lee
2021 年 2 月 25 日
On way is to do it in a loop. After your code,
hold on
d = zeros(size(x)); % to hold distances from the first point
for i = 2:numel(x)
plot3(x([1,i]),y([1,i]),z([1,i]),'-k','LineWidth',2)
d(i) = sqrt((x(1)-x(i))^2+(y(1)-y(i))^2+(z(1)-z(i))^2)
end
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!