function
MathUtilities.clip
Clamp a scalar to a closed interval
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | value | Real | | Value to clamp |
| input | lower | Real | | Lower interval bound |
| input | upper | Real | | Upper interval bound |
| output | result | Real | | Clamped value |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function clip "Clamp a scalar to a closed interval"
input Real value "Value to clamp";
input Real lower "Lower interval bound";
input Real upper "Upper interval bound";
output Real result "Clamped value";
algorithm
result := min(max(value, lower), upper);
annotation(Inline = true);
end clip;