Learn R Programming

pracma (version 0.9.6)

interv_union: Interval Functions

Description

Functions for determining the union or intersection of a set of (closed) intervals of the real number line.

Usage

interv_union(M)
interv_intersect(M)

Arguments

M
matrix representing a set of intervals.

Value

  • Another matrix representing a set of intervals.

Details

Intersection is easy, as it is the interval from the maximum of left end points to the minimum of the right end points (or NULL if the maximum is greater than the minimum).

NEW: Vectorized according to an idea of William Dunlap on R-help 01-2012. OLD: For the union, the intervals are first ordered by left endpoints, then a simple loop checking intersection of two adjacent intervals.

Examples

Run this code
set.seed(8237)
x <- sample(1:100, 10)
M <- cbind(x, x+10)

interv_union(M)
interv_intersect(M)

Run the code above in your browser using DataLab