Draw Lines between Points in MATLAB


by S_David
Tags: draw, lines, matlab, points
S_David
S_David is offline
#1
Apr14-11, 06:54 PM
P: 590
Hi,

I have a matrix V, which is a 5-by-2 matrix, where each row represents a point in the xy-plain. How can I connect these points together in MATLAB, please?

Thanks in advance
Phys.Org News Partner Science news on Phys.org
Better thermal-imaging lens from waste sulfur
Hackathon team's GoogolPlex gives Siri extra powers
Bright points in Sun's atmosphere mark patterns deep in its interior
jhae2.718
jhae2.718 is offline
#2
Apr14-11, 07:41 PM
PF Gold
jhae2.718's Avatar
P: 1,153
plot(V(:,1),V(:,2)) should do it, if I remember my matrix slicing.
S_David
S_David is offline
#3
Apr14-11, 07:45 PM
P: 590
Quote Quote by jhae2.718 View Post
plot(V(:,1),V(:,2)) should do it, if I remember my matrix slicing.
Ya, I tried this, but it does not work. It connects just between three points. I need to connect between all points to form a closed graph, starting from a point and ending at the same point.

Thanks

jhae2.718
jhae2.718 is offline
#4
Apr14-11, 07:50 PM
PF Gold
jhae2.718's Avatar
P: 1,153

Draw Lines between Points in MATLAB


It only plots three points?

I think you should be able to get a connected graph by appending the start point onto the matrix (getting a 6x2) and then using plot.
S_David
S_David is offline
#5
Apr14-11, 08:02 PM
P: 590
Quote Quote by jhae2.718 View Post
It only plots three points?

I think you should be able to get a connected graph by appending the start point onto the matrix (getting a 6x2) and then using plot.
Thank you very much. It is now working perfectly.
jhae2.718
jhae2.718 is offline
#6
Apr14-11, 08:16 PM
PF Gold
jhae2.718's Avatar
P: 1,153
Glad to hear it.
S_David
S_David is offline
#7
Apr14-11, 08:17 PM
P: 590
Quote Quote by jhae2.718 View Post
Glad to hear it.
If I want to extend it to 3D, is it straightforward to do that?
jhae2.718
jhae2.718 is offline
#8
Apr14-11, 08:20 PM
PF Gold
jhae2.718's Avatar
P: 1,153
You should probably be able to do something similar with plot3() for lines in R3.
S_David
S_David is offline
#9
Apr14-11, 10:47 PM
P: 590
Quote Quote by jhae2.718 View Post
You should probably be able to do something similar with plot3() for lines in R3.
That indeed works, but this connects all the points together. Actually, in 3D I just want to connect the adjacent points only. How can I do that?
jhae2.718
jhae2.718 is offline
#10
Apr14-11, 10:58 PM
PF Gold
jhae2.718's Avatar
P: 1,153
Quote Quote by S_David View Post
That indeed works, but this connects all the points together. Actually, in 3D I just want to connect the adjacent points only. How can I do that?
I'm not sure what exactly you mean by this...
S_David
S_David is offline
#11
Apr14-11, 11:01 PM
P: 590
Quote Quote by jhae2.718 View Post
I'm not sure what exactly you mean by this...
Neither do I. But basically, V is a matrix that contains the vertices of a polytope, and I want just to connect the adjacent vertices not all together. I am not sure how to know what are the adjacent vertices from V.

Thanks
jhae2.718
jhae2.718 is offline
#12
Apr14-11, 11:24 PM
PF Gold
jhae2.718's Avatar
P: 1,153
You may have to break the matrix up into matrices such that plot3 will produce the lines connected the way you want.

Another option is to look on the file exchange and see if there's anything you can use there. http://www.mathworks.com/matlabcentral/fileexchange/
S_David
S_David is offline
#13
Apr15-11, 11:09 AM
P: 590
Quote Quote by jhae2.718 View Post
You may have to break the matrix up into matrices such that plot3 will produce the lines connected the way you want.

Another option is to look on the file exchange and see if there's anything you can use there. http://www.mathworks.com/matlabcentral/fileexchange/
Ok, I will. Thank you.
jhae2.718
jhae2.718 is offline
#14
Apr15-11, 02:55 PM
PF Gold
jhae2.718's Avatar
P: 1,153
I think there may be a file on the exchange that will do what you want, otherwise I'm afraid I don't know of a built in function that will do what you want on only one call.


Register to reply

Related Discussions
draw a simpl graph in matlab Math & Science Software 2
Points, Lines, and Planes in 3D Space! Given 3 points find a plane... Calculus & Beyond Homework 10
How can I draw graphs for the equation on matlab Math & Science Software 1
points and lines Introductory Physics Homework 1
Two lines intersect at three points??? General Math 2