Borrar filtros
Borrar filtros

Extract x,y coordinates from plot function OR find coordinates between two x,y points

2 visualizaciones (últimos 30 días)
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,

Respuesta aceptada

Right Grievous
Right Grievous el 20 de Sept. de 2013
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.

Más respuestas (0)


Más información sobre Surface and Mesh Plots 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!

Translated by