How to connect points with given coordinates

48 visualizaciones (últimos 30 días)
emma glavich
emma glavich el 12 de Nov. de 2018
Comentada: emma glavich el 15 de Nov. de 2018
i have two sets of coordinates of given points and i was wandering if its possibile to plot them and to connect them with a line. so I basically have a matrix composed by 4 columns. In the first two there are the coordinates (x,y) of the first point and in the other two the coordinates of the other point, is it possible to plot them and connect the point from the first two columns to the point of the last two?

Respuesta aceptada

Adam Danz
Adam Danz el 12 de Nov. de 2018
Example data
mat = [1 1 11 10; 2 1 12 10; 3 1 13 10; 4 1 14 10; 5 1 15 10]
mat =
1 1 11 10
2 1 12 10
3 1 13 10
4 1 14 10
5 1 15 10
Solution
plot(mat(:,[1,3]), mat(:,[2,4]), 'o-')
  6 comentarios
Adam Danz
Adam Danz el 15 de Nov. de 2018
Editada: Adam Danz el 15 de Nov. de 2018
That shouldn't be the case.
First check that your data are organized in the same format as you described. You should have a matrix of 4 columns. Column 1 are the (x1) coordinates, column 2 are the (y1) coordinates, col 3 are the (x2) coordinates, and col 4 are the (y2) coordinates.
Second, check that you're properly setting up the plot:
plot(mat(:,[1,3])', mat(:,[2,4])', 'o-')
If you've checked these two items and you're certain they are correct but the plot still doesn't work, attach a subsection of the first 4-5 rows of your data and share the section of code that plots that data.
Since you have so many lines, check your plot by only plotting a few of the lines and check if those lines are correctly connecting the endpoints you expect them to connect. It could be the case that your code works but there's too many lines to see what's going on.
emma glavich
emma glavich el 15 de Nov. de 2018
Thank you very much for your time, you have been very kind!

Iniciar sesión para comentar.

Más respuestas (1)

emma glavich
emma glavich el 13 de Nov. de 2018
In this way point 1 (a11,a12) is connected to any other point in the comlums 3 and 4 (a23,a24...), right? is there a way to connect point 1 (a11,a12) to point 1 (a13,a14) and not to all the orher ones?
thank you very much
  1 comentario
Adam Danz
Adam Danz el 13 de Nov. de 2018
I replied in the comment section above since this is not an answer.

Iniciar sesión para comentar.

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by