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.

回答 (2 件)

dpb
dpb 2014 年 3 月 26 日

8 投票

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 件のコメント

Fahad Mirza
Fahad Mirza 2014 年 3 月 26 日
Ah...thanks! Sometimes the easy solution just don't come into the mind! ~sigh~
:)

サインインしてコメントする。

Erik Newton
Erik Newton 2024 年 8 月 29 日

1 投票

Since R2024a, there is now a clip function.

カテゴリ

ヘルプ センター および File ExchangeSimulink Functions についてさらに検索

質問済み:

2014 年 3 月 25 日

編集済み:

2024 年 8 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by