Values inside intervals
[xres, ind] = CL_intervSelectIn(interv, x [[, opt]])
Returns values that fall in at least one interval.
The returned values are sorted in increasing order.
The argument opt can be:
- "d": (d as "default") only values in x that are inside intervals are returned.
- "b": same as "d" + bounds of intervals (containing at least one value) are added.
- "bs": same as "b" + "%nan" separators are added between intervals.
The returned indices ind are not influenced by the value of opt. In default mode ("d"), xres == x(ind).
Notes:
- Only the union of intervals is considered. The returned bounds are the bounds of these intervals and not of the input ones.
- Input intervals of zero length are discarded.
- The output values are all different.
Set of intervals [start; end]. (2xN)
Set of values. (1xP)
(optional) Output option: "d", "b", "bs". Default is "d". (1x1 string)
Selected values (+ optional bounds and separators). (1xQ)
Indices of elements in x that belong to at least one interval. (1xR)
CNES - DCT/SB
// ------------------- // Example 1 // ------------------- interv = [[0.9; 2.9], [4.9; 6]]; x = [2, 2.5, 3, 4, 5, 5.5, 8, 5, 5]; // In "d" mode, only elements in x are returned (once). // Note that x(ind) contains duplicate values. [xres, ind] = CL_intervSelectIn(interv, x) x(ind) // In "b" mode, the bounds of the intervals that contain values // are also included: xres = CL_intervSelectIn(interv, x, opt="b") // In "bs" mode, NaNs are also added between interval bounds: xres = CL_intervSelectIn(interv, x, opt="bs") // ------------------- // Example 2: Use of "bs" mode // ------------------- x = linspace(0, 20, 100); interv = CL_detectSign(x, sin(x), "+"); vals = CL_intervSelectIn(interv, x, opt="bs"); scf(); plot(vals, sin(vals), "-o"); | ![]() | ![]() |