From: W. eWatson on
On 2/13/2010 11:35 PM, Rune Allnor wrote:
> On 14 Feb, 05:33, Walter Roberson<rober...(a)hushmail.com> wrote:
>
>> Calculating where the intersection of the lines *is* might be simple or
>> it might be computationally infeasible (for example, calculating the
>> exact location of the intersection of two chaotic curves might take
>> exceedingly long.)
>
> If the curves are represented as a set of ponts that are joined
> by linear segments, there exist algorithms that report the
> intersections in time proportional with the number of line segments
> and the number of intersections. This can be very much faster
> than brute-force searches, if only a few intersections exist.
>
> If, however, every segment intersects all other segments, then the
> worst-case performance is O(n^2) where n is the number of line
> segments.
>
> Just be aware that these algorithms rely heavily on dynamic search
> tree data structures, so I wouldn't implement this in matlab.
>
> Rune
>
>
Perhaps join would have been a better word. When I use plot in MPL, the
lines are like straight path segments that are connected.

It seems to me this should be easy. I have all the x,y pairs. Here's a
simple example. Start at (0,0). Next are (1,1.5) and (2.2). Plot draws
2 straight line segments. I want the marker at (1,1.5). Say a yellow
circle. plot(1,1.5,"yo")?

In Pyton MPL, it may be almost the same, but one usually needs some
qualifier like pyplot.plot(1,1.5, "yo") I have yet to find the right
combo.
From: Doug Schwarz on
In article <hl99ai$n3a$2(a)news.eternal-september.org>,
"W. eWatson" <wolftracks(a)invalid.com> wrote:

[snip]

> Perhaps join would have been a better word. When I use plot in MPL, the
> lines are like straight path segments that are connected.
>
> It seems to me this should be easy. I have all the x,y pairs. Here's a
> simple example. Start at (0,0). Next are (1,1.5) and (2.2). Plot draws
> 2 straight line segments. I want the marker at (1,1.5). Say a yellow
> circle. plot(1,1.5,"yo")?
>
> In Pyton MPL, it may be almost the same, but one usually needs some
> qualifier like pyplot.plot(1,1.5, "yo") I have yet to find the right
> combo.

It *is* easy, you just haven't been clear as to what you want. Since
matplotlib is modeled on MATLAB I think you'll find them to be quite
similar.

Suppose you have two vectors,

x = [0 1 2];
y = [0 1.5 2];

and you want to plot line segments only (two line segments connecting
the three points) then use

plot(x,y)

or you can be specific about the line style with

plot(x,y,'-')

To plot only three small circles at the endpoints of the segments use

plot(x,y,'o')

and to plot both connecting lines and the little circles use

plot(x,y,'o-')

See the help for the plot command for more details ("help plot" or "doc
plot"). Also, make sure you use single quotes in MATLAB to delimit
character strings.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
First  |  Prev  | 
Pages: 1 2
Prev: Please help
Next: Calculating the age of a person