Connect the dots with a loop
1 次查看(过去 30 天)
显示 更早的评论
Hi I have a point cloud :
point_cloud = [-1,0; 1,0; 1,2; -1,2; 0,3];
that I want connect according to two vectors :
k=[1 5 5 3 4]
l=[3 4 3 5 5]
it means : the first point is connected with the third, the fifth with the fourth
Here is my loop:
cc=point_cloud(:,1)
ll=point_cloud(:,2)
for m=1:size(k,1)
plot([point_cloud(k(m),1) point_cloud(l(m),1)],[point_cloud(k(m),2) point_cloud(l(m),2)])
hold on
end
plot(cc,ll,'r*')
hold off
but it draws only one segment
can you help me please
0 个评论
采纳的回答
Image Analyst
2015-4-29
In the first plot(), inside the loop, you need to tell it to do lines, like plot(....., 'r*-')
3 个评论
Image Analyst
2015-4-29
Try this:
point_cloud = [-1,0; 1,0; 1,2; -1,2; 0,3]
k=[1 5 5 3 4]
l=[3 4 3 5 5]
x=point_cloud(:,1)
y=point_cloud(:,2)
for m = 1 : length(k)
index1 = k(m)
index2 = l(m)
plot([x(index1), x(index2)],[y(index1), y(index2)], 'r*-', 'LineWidth', 2)
hold on
end
grid on;
hold off
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Point Cloud Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!