How to connect points with given coordinates
48 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuesta aceptada
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
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.
Más respuestas (1)
Ver también
Categorías
Más información sobre Visual Exploration 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!