<< CL_intervSearch Math CL_intervUnion >>

celestlab >> Math > CL_intervSelectIn

CL_intervSelectIn

Values inside intervals

Calling Sequence

[xres, ind] = CL_intervSelectIn(interv, x [[, opt]])

Description

Parameters

interv:

Set of intervals [start; end]. (2xN)

x:

Set of values. (1xP)

opt:

(optional) Output option: "d", "b", "bs". Default is "d". (1x1 string)

xres:

Selected values (+ optional bounds and separators). (1xQ)

ind:

Indices of elements in x that belong to at least one interval. (1xR)

See also

Authors

Examples

// -------------------
// 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");

Report an issue
<< CL_intervSearch Math CL_intervUnion >>