Function for limit range

334 views (last 30 days)
Fahad Mirza
Fahad Mirza on 25 Mar 2014
Commented: Fahad Mirza on 26 Mar 2014
Is there any function in matlab just like 'saturaion' 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.

Answers (1)

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

Sign in to comment.

Categories

Find more on Modeling in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!