This information is part of the Business Simulation Library (BSL). Please support this work and ► donate.
The function will clip a list of input values x
so that any component x_i
of x
will be x_i
for min ≤ x_i ≤ max
, min
for x_i < min
, and max
for x_i > max
.
Function.clip(x); // {min, max} = {-1,1}
Function.clip(x, {min, max});
Function.clip({-3,-2,-1,0,1,2,3}); // {-1,-1,-1,0,1,1,1}
Function.clip({-3,-2,-1,0,1,2,3},{-2,2}); // {-2,-2,-1,0,1,2,2}
This function is closely modeled to Clip
in the Wolfram Language.
function clip extends BusinessSimulation.Icons.Function; input Real x[:] "List of values to be clipped"; input Real[2] interval = {-1, 1} "Interval [min,max] given as a list (default = {-1,1})"; output Real y[size(x, 1)] "Clipped values"; end clip;
Inline = true
in v2.1.0.