Function for limit range

70 Ansichten (letzte 30 Tage)
Fahad Mirza
Fahad Mirza am 25 Mär. 2014
Bearbeitet: Walter Roberson am 29 Aug. 2024
Is there any function in matlab just like 'saturation' block in simulink? Which limit a input value within a range. If it exceeds the upper value it sets to the upper value and same for lower value.

Antworten (2)

dpb
dpb am 26 Mär. 2014
Not builtin but it's simple enough to create...
function y = bound(x,bl,bu)
% return bounded value clipped between bl and bu
y=min(max(x,bl),bu);
  1 Kommentar
Fahad Mirza
Fahad Mirza am 26 Mär. 2014
Ah...thanks! Sometimes the easy solution just don't come into the mind! ~sigh~
:)

Melden Sie sich an, um zu kommentieren.


Erik Newton
Erik Newton am 29 Aug. 2024
Since R2024a, there is now a clip function.

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by