clip
Limit values to a range.
📝Syntax
Y = clip(X, lowerBound, upperBound)
📥Input Arguments
Parameter Description
X a numeric or logical array.
lowerBound a numeric scalar: lower limit of the range.
upperBound a numeric scalar: upper limit of the range.
📤Output Arguments
Parameter Description
Y the clipped array, same size as X.
📄Description

clip limits the values of X to the interval [lowerBound, upperBound].

Values smaller than lowerBound are set to lowerBound and values greater than upperBound are set to upperBound.

NaN values in a floating-point input are preserved.

💡Examples
Y = clip([-2 0 5 10], 0, 8)
🔗See Also
minmax
🕔Version History
Version Description
1.13.0 initial version
Edit this page on GitHub