Thread Subject: plot line between two points

Subject: plot line between two points

From: nakisa

Date: 4 Mar, 2008 14:36:08

Message: 1 of 20

Hi everybody
I have a set of points :initial point (x1,y1) and final point
(x2,y2) . it is needed to plot a line between a initial and final
point .but I can't find a function for this aim in matlab's help .
Is there any thing available ?
Best, nakisa

Subject: plot line between two points

From: dpb

Date: 4 Mar, 2008 14:40:03

Message: 2 of 20

nakisa wrote:
> Hi everybody
> I have a set of points :initial point (x1,y1) and final point
> (x2,y2) . it is needed to plot a line between a initial and final
> point .but I can't find a function for this aim in matlab's help .
> Is there any thing available ?

plot() comes to mind...

--

Subject: plot line between two points

From: John D'Errico

Date: 4 Mar, 2008 15:02:02

Message: 3 of 20

dpb <none@non.net> wrote in message <fqjn98$jc3$1@aioe.org>...
> nakisa wrote:
> > Hi everybody
> > I have a set of points :initial point (x1,y1) and final point
> > (x2,y2) . it is needed to plot a line between a initial and final
> > point .but I can't find a function for this aim in matlab's help .
> > Is there any thing available ?
>
> plot() comes to mind...
>
> --

Or even line...

Gosh. If I wanted to plot a line, I wonder
what I might try? The OP might find a
utility like lookfor helpful.

Subject: plot line between two points

From: nakisa

Date: 4 Mar, 2008 15:13:19

Message: 4 of 20

hi
plot (x1,y1,x2,y2) doesn't good. it connects all points to each other.
but I want only for example (1.5,1.5) connected to (2.5,2.5)

Subject: plot line between two points

From: dpb

Date: 4 Mar, 2008 15:16:54

Message: 5 of 20

nakisa wrote:
> hi
> plot (x1,y1,x2,y2) doesn't good. it connects all points to each other.
> but I want only for example (1.5,1.5) connected to (2.5,2.5)

Perhaps following the instructions for plot() would help?

It says it will plot a vector y against vector x, or a matrix.

plot([x1 x2], [y1 y2])

--

Subject: plot line between two points

From: Christina Orphanidou

Date: 4 Mar, 2008 15:22:02

Message: 6 of 20

Hi,
you need to do the following:
x=[x1,x2]
y=[y1,y2]
plot(x,y)

Try this!
Christina

nakisa <nakisa.nooraee@gmail.com> wrote in message
<ec80902a-f806-4e81-bf79-d1b6b86b23f6@u10g2000prn.googlegroups.com>...
> hi
> plot (x1,y1,x2,y2) doesn't good. it connects all points to
each other.
> but I want only for example (1.5,1.5) connected to (2.5,2.5)

Subject: plot line between two points

From: Christophe Herault

Date: 4 Mar, 2008 15:51:02

Message: 7 of 20

"Christina Orphanidou" <c.orphanidou@gmail.com> wrote in
message <fqjpeq$2ne$1@fred.mathworks.com>...
> Hi,
> you need to do the following:
> x=[x1,x2]
> y=[y1,y2]
> plot(x,y)
>
> Try this!
> Christina
>
> nakisa <nakisa.nooraee@gmail.com> wrote in message
> <ec80902a-f806-4e81-bf79-
d1b6b86b23f6@u10g2000prn.googlegroups.com>...
> > hi
> > plot (x1,y1,x2,y2) doesn't good. it connects all points
to
> each other.
> > but I want only for example (1.5,1.5) connected to
(2.5,2.5)
>

Hi Christina,

Would you mean interpolate the datas between your range
data set ?

Regards,

Christophe

Subject: plot line between two points

From: Christophe Herault

Date: 4 Mar, 2008 15:54:02

Message: 8 of 20

Hi Christina,

Would you mean to do an interpolation within your dataset
range ?

Regards,

Christophe

Subject: plot line between two points

From: Christina Orphanidou

Date: 4 Mar, 2008 16:02:02

Message: 9 of 20

Hi Christophe,
no there is no interpolation. It's just defining the two
vectors you are plotting using the data you have. The
x-dimension vector is defined by points x1 and x2 (hence
x=[x1,x2]) and the y-dimension vector by y1 and y2
similarly. You then plot vector x against vector y.
Christina


"Christophe Herault" <christophe@plstechnologies.com> wrote
in message <fqjraq$299$1@fred.mathworks.com>...
> Hi Christina,
>
> Would you mean to do an interpolation within your dataset
> range ?
>
> Regards,
>
> Christophe

Subject: plot line between two points

From: Christophe Herault

Date: 4 Mar, 2008 16:25:03

Message: 10 of 20

So, i think he best way to do it is:

Set as vector the datas:
x=[x1,x2]
y=[y1,y2]

And plot the result:
plot(x,y)

That's all, well, i think :-)

Regards,

Christophe

Subject: plot line between two points

From: Christina Orphanidou

Date: 4 Mar, 2008 16:42:02

Message: 11 of 20

Hi Christophe,
I believe this is exactly what I suggested in message 6
above :-). Isn't it?
Christina

"Christophe Herault" <christophe@plstechnologies.com> wrote
in message <fqjt4v$k1$1@fred.mathworks.com>...
> So, i think he best way to do it is:
>
> Set as vector the datas:
> x=[x1,x2]
> y=[y1,y2]
>
> And plot the result:
> plot(x,y)
>
> That's all, well, i think :-)
>
> Regards,
>
> Christophe
>
>
>

Subject: plot line between two points

From: Christina Orphanidou

Date: 4 Mar, 2008 16:47:02

Message: 12 of 20

Hi Christophe,
I believe this is exactly what I suggested in message 6
above :-). Isn't it?
Christina

"Christophe Herault" <christophe@plstechnologies.com> wrote
in message <fqjt4v$k1$1@fred.mathworks.com>...
> So, i think he best way to do it is:
>
> Set as vector the datas:
> x=[x1,x2]
> y=[y1,y2]
>
> And plot the result:
> plot(x,y)
>
> That's all, well, i think :-)
>
> Regards,
>
> Christophe
>
>
>

Subject: plot line between two points

From: Christophe Herault

Date: 4 Mar, 2008 17:25:03

Message: 13 of 20

"Christina Orphanidou" <c.orphanidou@gmail.com> wrote in
message <fqjue6$ins$1@fred.mathworks.com>...
> Hi Christophe,
> I believe this is exactly what I suggested in message 6
> above :-). Isn't it?
> Christina

Absolutly Chris,

You're right but what could be other solutions ?
I think, like others, that this solution is most eficient
and by the way, the best.

Regards,

Christophe

Subject: plot line between two points

From: nakisa

Date: 5 Mar, 2008 07:08:10

Message: 14 of 20

hi
both of these ways produce one result ,that is not what I want. i
connects all points to each other!!!!1

Subject: plot line between two points

From: Christina Orphanidou

Date: 5 Mar, 2008 10:10:07

Message: 15 of 20

Dear Nakisa,
I am certain that what I suggested is the solution.
If for example you want to connect points [1,3] and [2,5]
what you need to do is define the x-dimension vector, then
the y-dimension vector and plot one against the other.
i.e.
x=[1,2]
y=[3,5]
plot(x,y)
This will give you a line connecting [1,3] and [2,5]. For
sure! Isn't that what you are trying to do?
Christina
 
nakisa <nakisa.nooraee@gmail.com> wrote in message
<9ed44ee5-6e12-4d6b-a039-a7ad61ce86d0@34g2000hsz.googlegroups.com>...
> hi
> both of these ways produce one result ,that is not what I
want. i
> connects all points to each other!!!!1
>

Subject: plot line between two points

From: Pekka

Date: 5 Mar, 2008 10:23:04

Message: 16 of 20

nakisa <nakisa.nooraee@gmail.com> wrote in message
<9ed44ee5-6e12-4d6b-a039-
a7ad61ce86d0@34g2000hsz.googlegroups.com>...
> hi
> both of these ways produce one result ,that is not what I
want. i
> connects all points to each other!!!!1
>

Isn't that exactly what you wanted?? Give those two points
to plot() and it will connect all those two points with a
line.

Or is it indexind that is bothering here? How to pick the
first and last element from vectors?
Is this what you need?
plot(x([1 end]),y([1 end]))
This will connect the first and the last point of your
vectors x and y.

Subject: plot line between two points

From: dvt

Date: 5 Mar, 2008 13:33:45

Message: 17 of 20

nakisa wrote:
> hi
> both of these ways produce one result ,that is not what I want. i
> connects all points to each other!!!!1

You *don't* want the points connected by a line? Try something like this:

plot(x,y,'ko')

That should put a black circle at each data point. The help for the plot
function gives you choices for colors and shapes other than a black circle.

--
Dave
dvt at psu dot edu

Subject: plot line between two points

From: nakisa

Date: 9 Mar, 2008 16:45:26

Message: 18 of 20

Hi Christina
I try your code and it is OK now.
thanks ,nakisa

Subject: plot line between two points

From: us

Date: 9 Mar, 2008 18:33:07

Message: 19 of 20

nakisa:
<SNIP trying to plot two points...

> ...it is OK now...

wow, after 17 replies! this thread shows the incredible
efficiency of both ML and CSSM...

us

Subject: plot line between two points

From: Dahai

Date: 20 Jan, 2010 14:19:19

Message: 20 of 20

You might also think of using
[x y] = intline(x1, x2, y1, y2)
to get the line point coordinates for background manipulation.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
humor us 9 Mar, 2008 14:35:10
rssFeed for this Thread

Contact us at files@mathworks.com