clip

Clip values so they do not extend beyond a given interval

Information

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

Syntax


Function.clip(x);               // {min, max} = {-1,1}
Function.clip(x, {min, max}); 

Examples


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}

Notes

This function is closely modeled to Clip in the Wolfram Language.

Syntax

y = clip(x, interval)

Inputs (2)

x

Type: Real[:]

Description: List of values to be clipped

interval

Default Value: {-1, 1}

Type: Real[2]

Description: Interval [min,max] given as a list (default = {-1,1})

Outputs (1)

y

Type: Real[size(x, 1)]

Description: Clipped values

Revisions

  • Added Inline = true in v2.1.0.