3D line plot between coordinates
3 次查看(过去 30 天)
显示 更早的评论
I am trying to make a function that draws lines between given coordinates in a MAT file. As an example, the MAT file can look as following. Where the second and third column are the x coordinates for the start and end of the point, the 4th and 5th for y and 6th and 7th for z.
The function nearly works as intended, and draws the three lines i specified. However, it adds one lines from (0,-6,24) to (18,-6,0). Anyone have an idea of how to make the function only draw the number of lines specified from the MAT file?
[1] [0] [ 0] [-6] [-6] [ 0] [ 24]
[1] [0] [ 18] [-6] [-6] [ 0] [ 0]
[1] [0] [14.5000] [-6] [-6] [24] [2.5000]
n = size(A.save_lines);
for i = 1:n(1)
X_start(i,1) = A.save_lines{i,2};
X_end(i,1) = A.save_lines{i,3};
Y_start(i,1) = A.save_lines{i,4};
Y_end(i,1) = A.save_lines{i,5};
Z_start(i,1) = A.save_lines{i,6};
Z_end(i,1) = A.save_lines{i,7};
end
X = [X_start , X_end]
Y = [Y_start , Y_end]
Z = [Z_start , Z_end]
X = reshape(X.',1,[])
Y = reshape(Y.',1,[])
Z = reshape(Z.',1,[])
line(X,Y,Z)
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!