Function for limit range

62 vues (au cours des 30 derniers jours)
Fahad Mirza
Fahad Mirza le 25 Mar 2014
Modifié(e) : Walter Roberson le 29 Août 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.

Réponses (2)

dpb
dpb le 26 Mar 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 commentaire
Fahad Mirza
Fahad Mirza le 26 Mar 2014
Ah...thanks! Sometimes the easy solution just don't come into the mind! ~sigh~
:)

Connectez-vous pour commenter.


Erik Newton
Erik Newton le 29 Août 2024
Since R2024a, there is now a clip function.

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by