Find path between two points with X and Y coordinates
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Erkin Karatas
el 29 de Dic. de 2019
Comentada: darova
el 29 de Dic. de 2019
Hi all, I want to draw path between points, but the paths cannor be diagonal. Therefore the paths should have corners. Think it as a rectangle, you want to move from a corner to another corner, but cannot move diagonally. How can I show that on matlab? The coordinates are attached.
Thanks
2 comentarios
Respuesta aceptada
darova
el 29 de Dic. de 2019
I reached a succes
p = xlsread('coordinates');
x = p(:,1);
y = p(:,2);
plot(x,y,'.r')
hold on
for i = 1:length(x)-1
plot([x(i) x(i+1)],[y(i) y(i)])
plot([x(i+1) x(i+1)],[y(i) y(i+1)])
pause(0.5)
end
hold off
5 comentarios
darova
el 29 de Dic. de 2019
- While visiting the points in the file 'coordinate' if I the line crosses an obstacle(which is attached as file)
It's too complicated for this forum. You should incorporate your own script
To connect each point with each points use this code:
for i = 1:length(x)-1
for j = i+1:length(x)-1
plot([x(i) x(j)],[y(i) y(i)])
plot([x(j) x(j)],[y(i) y(j)])
pause(0.01)
end
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!