From: "Theodor Zouk" <>
Newsgroups: comp.soft-sys.matlab
Subject: Find indices where overlapping intervals occurs
Date: Tue, 1 Nov 2011 07:33:29 +0000 (UTC)
Organization: Univ of Umea
Lines: 19
Message-ID: <j8o7c9$m9m$>
Reply-To: "Theodor Zouk" <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1320132809 22838 (1 Nov 2011 07:33:29 GMT)
NNTP-Posting-Date: Tue, 1 Nov 2011 07:33:29 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1540208
Xref: comp.soft-sys.matlab:747807

Im having a problem getting the indices (integers) from overlapping intervals. Let me explain:

let's say for instance that I have some intervals belonging to say 

set A:

set B:

The indices(integers), where the intervals of set A overlaps with intervals of set B could easily be found by using the matlab "intersect" function after constructing the intervalls to vectors. Now this is not an option to me due to my intervals could hold a couple of hundred millions elements (integers) if made to vectors, so i just have to work with the the start and end values for each intervall. I should mention that all my intervals are closed intervals and positive integers. I have tried to use nestled loops but get lost in translation such of speech... Im wondering if there exists some solution (maybe mathematical formula) to find the indices(integers) where intervals overlaps based only on the start and end values. 

Best regards