Function for limit range

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.

Respuestas (2)

dpb
dpb el 26 de Mzo. de 2014

8 votos

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 comentario

Fahad Mirza
Fahad Mirza el 26 de Mzo. de 2014
Ah...thanks! Sometimes the easy solution just don't come into the mind! ~sigh~
:)

Iniciar sesión para comentar.

Erik Newton
Erik Newton el 29 de Ag. de 2024

1 voto

Since R2024a, there is now a clip function.

Categorías

Más información sobre Simulink Functions en Centro de ayuda y File Exchange.

Preguntada:

el 25 de Mzo. de 2014

Editada:

el 29 de Ag. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by