Borrar filtros
Borrar filtros

Connect the dots with a loop

1 visualización (últimos 30 días)
arnaud ensberg
arnaud ensberg el 29 de Abr. de 2015
Comentada: arnaud ensberg el 30 de Abr. de 2015
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

Respuesta aceptada

Image Analyst
Image Analyst el 29 de Abr. de 2015
In the first plot(), inside the loop, you need to tell it to do lines, like plot(....., 'r*-')
  3 comentarios
Image Analyst
Image Analyst el 29 de Abr. de 2015
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
arnaud ensberg
arnaud ensberg el 30 de Abr. de 2015
Thank you very much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Point Cloud Processing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by