From: Faisal Ahmed on 16 Jul 2010 23:42 I need help in plotting lines between points. Suppose, I start with creating 6 random points- x = rand(6,1); y = rand(6,1); So my points are (x(1),y(1)), (x(2),y(2)), (x(3),y(3)), (x(4),y(4)), (x(5),y(5)), (x(6),y(6)) Now I want to draw straight lines between the points 1 & 5, 2 & 6, 3 & 4 and plot them in a single diagram. So I get 3 straight lines. Any help would be highly appreciated.
From: zac on 17 Jul 2010 03:26 "Faisal Ahmed" <fap87(a)yahoo.com> wrote in message <i1r8qd$s1n$1(a)fred.mathworks.com>... > I need help in plotting lines between points. > Suppose, I start with creating 6 random points- > > x = rand(6,1); > y = rand(6,1); > > So my points are (x(1),y(1)), (x(2),y(2)), (x(3),y(3)), (x(4),y(4)), (x(5),y(5)), (x(6),y(6)) > > Now I want to draw straight lines between the points 1 & 5, 2 & 6, 3 & 4 > and plot them in a single diagram. So I get 3 straight lines. > > Any help would be highly appreciated. Maybe that? clear clc close all x = rand(6,1); y = rand(6,1); line([x(1) x(5)],[y(1) y(5)]) hold on line([x(2) x(6)],[y(2) y(6)]) hold on line([x(3) x(4)],[y(3) y(4)])
From: Jan Simon on 17 Jul 2010 06:19 Dear Faisal, > x = rand(6,1); > y = rand(6,1); > So my points are (x(1),y(1)), (x(2),y(2)), (x(3),y(3)), (x(4),y(4)), (x(5),y(5)), (x(6),y(6)) > Now I want to draw straight lines between the points 1 & 5, 2 & 6, 3 & 4 > and plot them in a single diagram. So I get 3 straight lines. Try this: figure; line(rand(2, 3), rand(2, 3)); Good luck, Jan
From: us on 17 Jul 2010 07:23 "zac " > line([x(1) x(5)],[y(1) y(5)]) > hold on > line([x(2) x(6)],[y(2) y(6)]) > hold on > line([x(3) x(4)],[y(3) y(4)]) note: you do NOT need HOLD if you use LINE... us
From: Faisal Ahmed on 18 Jul 2010 10:51 thanx a lot everyone. my problem is solved! -Faisal
|
Pages: 1 Prev: Neural Network with Image compression Next: fmincon Hessian standard errors |