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!