function
LieGroups.Util.saturate
Clamp scalar to [x_min, x_max]
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | x | Real | | |
| input | x_min | Real | | |
| input | x_max | Real | | |
| output | y | Real | |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function saturate "Clamp scalar to [x_min, x_max]"
input Real x;
input Real x_min;
input Real x_max;
output Real y;
algorithm
y := if x > x_max then x_max elseif x < x_min then x_min else x;
end saturate;