how to plot a line between two centroids in matlab

I am able to locate centroids of each blocks, but i am unable to join two blocks with a line segment by avoiding the obstacle as shown in the figure. Please need help how do i achieve this using matlab.

• If you want programming help, you should include sample code (especially your world definition). Also, we are assuming that this is a robot navigation problem, but you should state this if it is the case--otherwise, there are very simple algorithms that can connect the centroids while avoiding the obstacle. – JSycamore Jul 6 '16 at 21:30

Sorry I do not know. But following course has your needed info

Some course can register while not running. Some need wait for run time.

Low-level motion (PID, point a to b) https://www.coursera.org/course/conrob.

High level path planning https://www.edx.org/course/tumx/tumx-autonavx-autonomous-navigation-1658

part 1 and of of this, https://courses.edx.org/courses/SNUx/SNU446.345.1x/1T2014/info

• okay so can you tell me, how to join two blocks with a line segment, ignoring the obstacle, i mean how can i draw a straight line between two blocks. – Nabajyoti Das Aug 3 '14 at 17:34
• Block_1 x0,y0 Block_2_Robot x1,y1,speed,angle_of_movement (by robot sterling wheel as in 4 wheels car or differential drive for 2 wheel robot) – EEd Aug 3 '14 at 17:39
• as this diagram, where robot is, where to go and what angle to go. intechopen.com/source/html/9117/media/image36.png – EEd Aug 3 '14 at 17:47
• Am having difficulty with the coding part in matlab. I want to join the robot with the block by a line segment and then i want to move the robot by using the line segment as the reference point. – Nabajyoti Das Aug 3 '14 at 17:53

Have you tried the line() function, which plots a straight line on a figure?

You do something like

imshow(myImage);
hold on
line(X, Y);


Check help line for details.

• ya i did, but actually i am unable to do so, can you please provide me a sample code. – Nabajyoti Das Aug 5 '14 at 16:22