Intervals where a condition is met
[interv] = CL_intervFromCond(condition [[, x, margin]])
Computation of intervals where a condition is met.
The condition is defined by the argument condition which is an array of booleans.
The result interv is the set of intervals of the variable x where "condition" is true.
By default, x is defined as "1 : N", where N is the number of elements in the argument "condition".
The argument margin enables increasing or reducing the interval lengths:
- If "margin" is positive, the intervals are enlarged by margin * "one step" on either side (except if the upper or lower bounds are reached).
- If "margin" is negative, the intervals are shrinked by |margin| * "one step" on either side (except if the upper or lower bounds are reached).
Note:
No check is performed on the abscissa "x", in particular, it is not checked that all values are unique, or given in increasing order.
(boolean) Condition to be met. (1xN)
(optional) Corresponding abscissa. Default is 1:N. (1xN)
(optional) Relative margin (between -1 and 1). Default value is 0. (1x1)
Intervals where "condition" is true. (2xP)
CNES - DCT/SB
x = linspace(0, 10, 101); condition = (cos(x) > 0.2); // Intervals of x interv = CL_intervFromCond(condition, x) // Intervals of indices interv = CL_intervFromCond(condition) // Same result as above interv = CL_intervFromCond(condition, 1 : length(x)) // Intervals of x with +50% margin interv = CL_intervFromCond(condition, x, margin = 0.5) | ![]() | ![]() |