Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: checking for overlap

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20085] Re: checking for overlap
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Thu, 30 Sep 1999 02:43:04 -0400
  • References: <7ssfbm$bgd@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

DennisW555 <dennisw555 at aol.com> wrote in message
news:7ssfbm$bgd at smc.vnet.net...
> I am looking for an elegant way of checking for overlap.
>
> Suppose I have a set of time intervals given by
> ints = {{t1,t2},{t3,t4},{t5,t6}. ...} and another set of times
> tvals = {u1,u2,u3, ...}.
>  What is a fast, elegant way of checking which of the tvals is within any
of
> the ints time intervals?
>
> Thanks,
> Dennis
>

Dennis,


ints = Table[Random[], {7}, {2}];
tvals = Table[Random[], {9}];

Cases[Outer[List, tms, ints, 1],
  {t_, {a_, b_}} /; a <= t <= b, {2}]

If the tvals are also intervals and you are interested in containment, then
a similar code works.
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565






  • Prev by Date: Is it possible to start a perl executable from mathematica?
  • Next by Date: Re: NSolve with conditions
  • Previous by thread: Re: checking for overlap
  • Next by thread: Re: checking for overlap