Asked by Right Grievous
on 20 Sep 2013

Hi again everybody,

I have pairs of coordinates [x,y] which I can use to plot a nice figure of lines. However, I need to use the coordinates between these two points.

I either need to find the coordinates between them, or I need to plot a line between them using plot or some other function and then extract the x,y values of the line (this info must be stored somewhere right?).

interp1 has been suggested for another question but I get an error when trying to use this - possibly because the distance between the two points is a decimal? This is the error:

**Error using griddedInterpolant The point coordinates are not sequenced in strict monotonic order.**

The same goes for using linspace to create a series of coordinates, the number of coordinates I would need it to create would be a decimal, which it can't do. This is the error:

**Warning: Integer operands are required for colon operator when used as index**

Thank you for any help,

Rod.

*No products are associated with this question.*

Answer by Right Grievous
on 20 Sep 2013

Accepted answer

I answered my own question again:

In my case I had the option of changing the coordinates slightly - I wasn't trying to find the coordinates of a fixed line, so this probably isn't much use to anyone.

Basically I made the distance of my line a whole number, by altering my x value slightly (I used Pythagoras' theorem to find the distance, then round it and then work out the new x value I would need to get this distance).

Once my distance was a whole number I used linspace to create a vector of x and y values between my points i.e. linspace(xvalue1,xvalue2,distance_between_them) and voila!, I have the coordinates I needed.

Rod.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments