Learn R Programming

pracma (version 1.9.3)

findintervals: Find Interval Indices

Description

Find indices i in vector xs such that either x=xs[i] or such that xs[i] or xs[i]>x>xs[i+1].

Usage

findintervals(x, xs)

Arguments

x
single number.
xs
numeric vector, not necessarily sorted.

Value

Vector of indices in 1..length(xs). If none is found, returns integer(0).

Details

Contrary to findInterval, the vector xs in findintervals need not be sorted.

Examples

Run this code
xs <- zapsmall(sin(seq(0, 10*pi, len=100)))
findintervals(0, xs)
#   1  10  20  30  40  50  60  70  80  90 100

Run the code above in your browser using DataLab