Find path between two points with X and Y coordinates
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
darova
on 29 Dec 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 Comments
darova
on 29 Dec 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
More Answers (0)
See Also
Categories
Find more on Axes Appearance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!