.BusinessSimulation.Functions.clip

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.

Interface

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;

Revisions


Generated at 2024-11-23T19:25:52Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos